validatit
v1.0.17
Published
A package that makes json validation easier
Downloads
30
Maintainers
Readme
Validatit helps you to validate JSON objects.
🏠 Homepage
Install
npm i validatit@latest
Usage
import {validatit} from 'validatit'
Call validatit function
let json = {
first_name:"jamie",
phone:"+18889203388",
address:{
street:""
}
};
let params=[
{name:"*first_name:STRING"},
{name:"*phone:PHONE"} ,
{
name:"address",
params:[
{name:"*street"}
]
}
];
let res = await validatit(json,params);
Params
Parameter name | description | example | notes --- | --- | --- | --- name | name of the parameter to ve validated | name:"first_name" | required | indicates that the parameter is mandatory | {name:"first_name" ,required:true} | you can use {name:"first_name"} instead to have smaller validators type | parameter type. Current types are :ARRAY, OBJECT, BOOLEAN, STRING, NUMBER, FUNCTION, DATE, CREDIT_CARD, EMAIL, PHONE, ANY | {name:"first_name" ,type:"STRING"} | you can use {name:"first_name:STRING"} instead to have smaller validators pattern | custom regular expression | {name:"first_name",pattern:/^[A-Z][a-z]+(?:[A-Z][a-z]+)$/} | dynamicValidation | used for custom runtime validations | {name:"first_name",dynamicValidation:asyc(body)=>return {success:true,error_message:""}} |
Run tests
npm run test
Author
👤 Bahram Ghahari
- Github: @bahram-ghahari
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2021 Bahram Ghahari. This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator