Platform-agnostic validation library for JavaScript applications with extra focus on composable validations and message translations. Includes (pretty much) out-of-the-box support for both Redux Form and React Intl.
Create your validation schema based on priciples of functional programming.
Open Validarium in a RunKit sandbox!
import { validate, isRequired, isEmail, hasLengthMax, hasValueMin } from 'validarium';
const validateUserForm = validate({
email: [isRequired, isEmail, hasLengthMax(200)],
age: [isRequired, isNumber, hasValueMin(18)],
});
validateUserForm({ email: 'something', age: 16 });
// Returns { email: EmailMessage, age: NumberMessage }
//
// EmailMessage is { id: 'validarium.isEmail', defaultMessage: 'Not a valid email format' }
// NumberMessage is { id: 'validarium.isNumber', defaultMessage: 'Not a number' }
Every validation is optional and null-safe. If you want to test against null
, please use the isRequired
validation.
Of course, validating field arrays, combining multiple validation schemas, and overriding validation messages with custom ones is supported as well.
Use either of these commands based on the package manager you prefer.
yarn add validarium
npm i validarium
It is possible to use validarium
to start quickly prototype directly in browser.
We provide two Universal Module Definition (UMD) bundles:
- development version: https://unpkg.com/validarium@latest/dist/validarium.js
- production version: https://unpkg.com/validarium@latest/dist/validarium.min.js
- @redux-tools – Maintaining large Redux applications with ease.
- react-union – Integrate React apps into various CMSs seamlessly.
- lundium – Beautiful React component library.
We are open to all ideas and suggestions, feel free to open an issue or a pull request!
See the contribution guide for guidelines.
- @redux-tools – Maintaining large Redux applications with ease.
- react-union – Integrate React apps into various CMSs seamlessly.
- lundium – Beautiful React component library.
All packages are distributed under the MIT license. See the license here.