Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcisbee/valide
💠Simple, chainable, multi lingual data validator
https://github.com/marcisbee/valide
chainable checker i18n javascript js nodejs type validation validator
Last synced: 2 days ago
JSON representation
💠Simple, chainable, multi lingual data validator
- Host: GitHub
- URL: https://github.com/marcisbee/valide
- Owner: Marcisbee
- License: mit
- Created: 2018-11-14T10:09:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-05T09:17:57.000Z (over 1 year ago)
- Last Synced: 2024-11-09T07:12:19.186Z (7 days ago)
- Topics: chainable, checker, i18n, javascript, js, nodejs, type, validation, validator
- Language: JavaScript
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Valide
[![discord](https://dcbadge.vercel.app/api/server/a62gfaDW2e?style=flat-square)](https://discord.gg/a62gfaDW2e)
Valide is simple, chainable, multi lingual data validator.
## Installation
To install the stable version:
```
npm install --save valide
```This assumes you are using [npm](https://www.npmjs.com/) as your package manager.
If you're not, you can [access these files on unpkg](https://unpkg.com/valide/dist/), download them, or point your package manager to them.
#### Browser Compatibility
Valide.js currently is compatible with browsers that support at least ES3.
## Example usage
```js
import { Valide } from 'valide';function validateEmail(value) {
return new Valide(value)
.required()
.email()
.error('E-mail :email is invalid!', { email: value })
.check();
}validateEmail(''); // -> "Field is required"
validateEmail('foo'); // -> "E-mail foo is invalid!"
validateEmail('[email protected]'); // -> true
```Valide chain must always end with `.check()` to evaluate value.
Check method also can take in new value to check against rule set.Every rule can have custom error message. To add it, simply chain `.error(string [, params])` after rule. By default every rule has english error message.
### Currently available rules:
- `.required()`
- `.test(regex)`
- `.includes(string)`
- `.excludes(string)`
- `.equal(string)`
- `.notEqual(string)`
- `.min(number)`
- `.max(number)`
- `.email(string)`---
- `.error(string [, params])`
## Stay In Touch
- [Twitter](https://twitter.com/radi_js)
- [Slack](https://join.slack.com/t/radijs/shared_invite/enQtMjk3NTE2NjYxMTI2LWFmMTM5NTgwZDI5NmFlYzMzYmMxZjBhMGY0MGM2MzY5NmExY2Y0ODBjNDNmYjYxZWYxMjEyNjJhNjA5OTJjNzQ)## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2018-present, Marcis (Marcisbee) Bergmanis