1.0.17 ā€¢ Published 3 years ago

validatit v1.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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 namedescriptionexamplenotes
namename of the parameter to ve validatedname:"first_name"
requiredindicates that the parameter is mandatory{name:"first_name" ,required:true}you can use {name:"*first_name"} instead to have smaller validators
typeparameter 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
patterncustom regular expression{name:"first_name",pattern:/^A-Z+(?:A-Z+)*$/}
dynamicValidationused for custom runtime validations{name:"first_name",dynamicValidation:asyc(body)=>return {success:true,error_message:""}}

Run tests

npm run test

Author

šŸ‘¤ 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

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago