|
1 | 1 | # @qavajs/validation
|
2 | 2 |
|
3 |
| -``` |
| 3 | +A `@qavajs` library for validating data using plain English definitions. This package simplifies the process of creating validation functions by translating human-readable sentences into executable code. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +You can install the library using `npm`: |
| 8 | + |
| 9 | +```bash |
4 | 10 | npm install @qavajs/validation
|
5 | 11 | ```
|
6 | 12 |
|
7 |
| -@qavajs library that transforms plain english definition to validation functions |
8 |
| - |
9 |
| -Library supports following validations: |
10 |
| -* equal - not strict equal (==) |
11 |
| -* strictly equal - strict equal (===) |
12 |
| -* deeply equal - deep equal (chai eql) |
13 |
| -* contain - contain a substring |
14 |
| -* match - match a regular expression |
15 |
| -* above / greater than - greater than |
16 |
| -* below / less than - less than |
17 |
| -* have type - type validation |
18 |
| -* have members - validation if array/object have exact members |
19 |
| -* include members - validation if array/object includes members |
20 |
| -* have property - have property validation |
21 |
| -* match schema - match [ajv](https://www.npmjs.com/package/ajv) schema |
22 |
| -* case insensitive equal - not strict equal (==) with casting to lower case |
23 |
| - |
24 |
| -All validations can be negated adding `not` word. |
| 13 | +## Supported Validations |
| 14 | + |
| 15 | +This library supports a variety of validation types, which can all be negated by adding the word `not`. |
| 16 | + |
| 17 | +### Equality & Comparison |
| 18 | + |
| 19 | + - **`equal`**: Checks for non-strict equality (`==`). |
| 20 | + - **`strictly equal`**: Checks for strict equality (`===`). |
| 21 | + - **`deeply equal`**: Performs a deep comparison of object properties or array elements. |
| 22 | + - **`case insensitive equal`**: Compares two values for non-strict equality after converting them to lowercase. |
| 23 | + - **`contain`**: Verifies if a string contains a specific substring. |
| 24 | + - **`include members`**: Checks if an array or object includes a specific set of members. |
| 25 | + - **`have members`**: Validates if an array or object has an exact match of a specified set of members. |
| 26 | + - **`have property`**: Ensures an object has a particular property. |
| 27 | + - **`above`** / **`greater than`**: Checks if a value is greater than another. |
| 28 | + - **`below`** / **`less than`**: Checks if a value is less than another. |
| 29 | + - **`match`**: Validates if a string matches a regular expression. |
| 30 | + - **`have type`**: Checks the type of a variable (e.g., `string`, `number`, `boolean`). |
| 31 | + - **`match schema`**: Validates data against an [ajv](https://www.npmjs.com/package/ajv) schema, which is useful for complex object validation. |
25 | 32 |
|
26 | 33 | ## Test
|
27 | 34 |
|
28 |
| -``` |
| 35 | +To run the test suite for this package, use the following command: |
| 36 | + |
| 37 | +```bash |
29 | 38 | npm run test
|
30 | 39 | ```
|
| 40 | + |
| 41 | +## License |
| 42 | + |
| 43 | +This project is licensed under the MIT License. |
0 commit comments