https://github.com/lundegaard/validarium
🛡Agnostic validation library for JavaScript applications.
https://github.com/lundegaard/validarium
formik intl ramda react redux-form validations
Last synced: 2 months ago
JSON representation
🛡Agnostic validation library for JavaScript applications.
- Host: GitHub
- URL: https://github.com/lundegaard/validarium
- Owner: lundegaard
- License: mit
- Created: 2018-11-23T12:03:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:40:08.000Z (over 2 years ago)
- Last Synced: 2025-03-29T14:36:40.730Z (3 months ago)
- Topics: formik, intl, ramda, react, redux-form, validations
- Language: JavaScript
- Homepage: https://validarium.js.org
- Size: 2.72 MB
- Stars: 29
- Watchers: 4
- Forks: 9
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
🖍️ 🛡 🚀
Validations done right.
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!
```js
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.
## Installation
Use either of these commands based on the package manager you prefer.
```sh
yarn add validarium
``````sh
npm i validarium
```### CDN
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](https://unpkg.com/validarium@latest/dist/validarium.js)
- production version: [https://unpkg.com/validarium@latest/dist/validarium.min.js](https://unpkg.com/validarium@latest/dist/validarium.js)⚠️ Using this approach in production is discouraged though - the client has to download the entire library, regardless of which functions are actually used, affecting performance and bandwidth utilization.
## Related projects
- [@redux-tools](https://github.com/lundegaard/redux-tools) – Maintaining large Redux applications with ease.
- [react-union](https://github.com/lundegaard/react-union) – Integrate React apps into various CMSs seamlessly.
- [lundium](https://github.com/lundegaard/lundium) – Beautiful React component library.## Contributing
We are open to all ideas and suggestions, feel free to open an issue or a pull request!
See the [contribution guide](contributing) for guidelines.
## License
All packages are distributed under the MIT license. See the license [here](https://github.com/lundegaard/validarium/blob/master/LICENSE).