4.13.1 • Published 1 year ago

@ambassify/ui-input-tv4 v4.13.1

Weekly downloads
182
License
MIT
Repository
github
Last release
1 year ago

ui-input-tv4

Input components enriched with a tv4 validator. You can pass the schema as a property on the various input components instead of a validator property.

To provide custom error messages or format validators, wrap your app in the <Tv4Container>.

Usage

import { TextField, Tv4Container, ErrorCodes } from '@ambassify/ui-input-tv4';

const messages = {
    [ErrorCodes.STRING_LENGTH_LONG]: ({ minimum }) => <span>Enter at least {minimum} characters</span>,
    'FORMAT.email': 'Please enter a valid e-mail address'
};

const formats = {
    'email': value => value.indexOf('@') > -1 ? null : 'It must be foo!'
};

class App extends React.Component {
    render() {
        return (
            <div>
                <TextField
                    label="Not customized"
                    schema={{ type: 'string', minLength: 2 }} />
                <Tv4Container messages={messages} formats={formats}>
                    <TextField
                        label="I have customized validation"
                        schema={{ type: 'string', format: 'email', minLength: 5 }} />
                </TV4Container>
            </div>
        );
    }
}

Error codes

These are taken from https://github.com/geraintluff/tv4/blob/master/tv4.js#L1370

var ErrorCodes = {
	INVALID_TYPE: 0,
	ENUM_MISMATCH: 1,
	ANY_OF_MISSING: 10,
	ONE_OF_MISSING: 11,
	ONE_OF_MULTIPLE: 12,
	NOT_PASSED: 13,
	// Numeric errors
	NUMBER_MULTIPLE_OF: 100,
	NUMBER_MINIMUM: 101,
	NUMBER_MINIMUM_EXCLUSIVE: 102,
	NUMBER_MAXIMUM: 103,
	NUMBER_MAXIMUM_EXCLUSIVE: 104,
	NUMBER_NOT_A_NUMBER: 105,
	// String errors
	STRING_LENGTH_SHORT: 200,
	STRING_LENGTH_LONG: 201,
	STRING_PATTERN: 202,
	// Object errors
	OBJECT_PROPERTIES_MINIMUM: 300,
	OBJECT_PROPERTIES_MAXIMUM: 301,
	OBJECT_REQUIRED: 302,
	OBJECT_ADDITIONAL_PROPERTIES: 303,
	OBJECT_DEPENDENCY_KEY: 304,
	// Array errors
	ARRAY_LENGTH_SHORT: 400,
	ARRAY_LENGTH_LONG: 401,
	ARRAY_UNIQUE: 402,
	ARRAY_ADDITIONAL_ITEMS: 403,
	// Custom/user-defined errors
	FORMAT_CUSTOM: 500,
	KEYWORD_CUSTOM: 501,
	// Schema structure
	CIRCULAR_REFERENCE: 600,
	// Non-standard validation options
	UNKNOWN_PROPERTY: 1000
};
4.13.0

1 year ago

4.13.1

1 year ago

4.12.1

2 years ago

4.12.0

2 years ago

4.11.1

2 years ago

4.11.2

2 years ago

4.11.3

2 years ago

4.10.5

2 years ago

4.10.6

2 years ago

4.10.1

2 years ago

4.10.2

2 years ago

4.10.3

2 years ago

4.10.4

2 years ago

4.10.0

2 years ago

4.11.0

2 years ago

4.8.0

2 years ago

4.7.0

2 years ago

4.7.2

2 years ago

4.7.1

2 years ago

4.6.7

2 years ago

4.6.6

2 years ago

4.6.3

2 years ago

4.6.0

2 years ago

4.5.1

2 years ago

4.4.1

3 years ago

4.4.0

3 years ago

4.5.0

2 years ago

4.3.1

3 years ago

4.3.4

3 years ago

4.3.0

3 years ago

4.2.1

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.1-alpha.0

3 years ago

4.0.1-alpha.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.11

3 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.2

4 years ago

3.0.0

4 years ago

3.0.0-beta.3

4 years ago

3.0.0-beta.4

4 years ago

3.0.0-beta.2

4 years ago

3.0.0-beta.1

4 years ago

3.0.0-beta.0

4 years ago

2.12.2

4 years ago

3.0.0-alpha.3

4 years ago

3.0.0-alpha.2

4 years ago

3.0.0-alpha.1

4 years ago

2.11.10

4 years ago

2.11.9

4 years ago

2.11.4

4 years ago

2.11.5

4 years ago

2.10.0

4 years ago

2.7.5

4 years ago

2.7.3

4 years ago

2.7.2

4 years ago

2.6.1

4 years ago

2.6.0

5 years ago

2.5.3

5 years ago

2.5.0

5 years ago

2.5.1

5 years ago

2.4.0

5 years ago

2.3.7

5 years ago

2.3.6

5 years ago

2.3.5

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.3.0-alpha.1

5 years ago

2.3.0-alpha.0

5 years ago

2.2.0

5 years ago

2.2.2

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.0

5 years ago

2.1.0-alpha.3

5 years ago

2.1.0-alpha.2

5 years ago

2.1.0-alpha.1

5 years ago

2.0.1

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.0

6 years ago

1.1.3

6 years ago

1.1.1

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.6.21-alpha.3

6 years ago

0.6.21-alpha.1

6 years ago

0.6.21-alpha.0

6 years ago

0.6.19

6 years ago

0.6.18

6 years ago

0.6.16

6 years ago

0.6.14

6 years ago

0.6.13

6 years ago

0.6.12

6 years ago

0.6.11

6 years ago

0.6.11-alpha.2

6 years ago

0.6.11-alpha.1

6 years ago

0.6.11-alpha.0

6 years ago

0.6.9

6 years ago

0.6.8

6 years ago

0.6.7

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.7

6 years ago

0.5.5

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.21

7 years ago

0.4.20

7 years ago

0.4.19

7 years ago

0.4.18

7 years ago

0.4.17

7 years ago

0.4.13

7 years ago

0.4.12

7 years ago

0.4.11

7 years ago

0.4.7

7 years ago

0.4.3

7 years ago

0.4.0

7 years ago