redux-form-create-validator
v0.1.3
Published
A helper utility that allows you to create redux form validations.
Downloads
4
Maintainers
Readme
Redux form create validator
A utility that allows you to create a validator for use with Redux Form (v.5.2.5)
Example Usage
import createValidator, * as validation from 'redux-form-create-validator';
import memoize from 'lru-memoize';
// Compose validation functions for all input fields
const passwordInput = [
validation.containsLowercase,
validation.containsUppercase,
validation.minLength(8),
validation.maxLength(20),
validation.containsNumber,
validation.valueRequired,
validation.containsSpecialChar,
];
const nameInput = [
validation.containsTwoWords,
validation.valueRequired,
validation.maxLength(50),
];
const emailInput = [
validation.isEmail,
validation.valueRequired,
validation.maxLength(50),
validation.minLength(2),
];
const passwordConfirmationInput = [
validation.valueRequired,
];
// Create the validator
const signupValidation = createValidator({
passwordInput,
nameInput,
emailInput,
passwordConfirmationInput,
});
/* Memoize and export */
const validator = memoize(10)(signupValidation);
export default validator;