@gmcode/tsv-input
v0.3.3
Published
Form input schema validations with i18n support.
Maintainers
Readme
@gmcode/tsv-input
Typescript schema validations for form inputs with i18n interpolation support.
Installation
npm install @gmcode/tsv-inputUsage
import { InputEmailRule, InputTextRule, Schema } from '@gmcode/tsv-input'
// Define the schema
const schema = new Schema({
name: new InputTextRule({
maxChars: 30,
minChars: 5
}),
email: new InputEmailRule({
maxChars: 120
})
})
// Validate some values
const result = schema.validate({
name: 'John',
email: '[email protected]'
})
if (result.success) {
// The input is valid
// ...
} else {
// Handle rejection
// ...
}