Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# @qavajs/validation

```
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.

## Installation

You can install the library using `npm`:

```bash
npm install @qavajs/validation
```

@qavajs library that transforms plain english definition to validation functions

Library supports following validations:
* equal - not strict equal (==)
* strictly equal - strict equal (===)
* deeply equal - deep equal (chai eql)
* contain - contain a substring
* match - match a regular expression
* above / greater than - greater than
* below / less than - less than
* have type - type validation
* have members - validation if array/object have exact members
* include members - validation if array/object includes members
* have property - have property validation
* match schema - match [ajv](https://www.npmjs.com/package/ajv) schema
* case insensitive equal - not strict equal (==) with casting to lower case

All validations can be negated adding `not` word.
## Supported Validations

This library supports a variety of validation types, which can all be negated by adding the word `not`.

### Equality & Comparison

- **`equal`**: Checks for non-strict equality (`==`).
- **`strictly equal`**: Checks for strict equality (`===`).
- **`deeply equal`**: Performs a deep comparison of object properties or array elements.
- **`case insensitive equal`**: Compares two values for non-strict equality after converting them to lowercase.
- **`contain`**: Verifies if a string contains a specific substring.
- **`include members`**: Checks if an array or object includes a specific set of members.
- **`have members`**: Validates if an array or object has an exact match of a specified set of members.
- **`have property`**: Ensures an object has a particular property.
- **`above`** / **`greater than`**: Checks if a value is greater than another.
- **`below`** / **`less than`**: Checks if a value is less than another.
- **`match`**: Validates if a string matches a regular expression.
- **`have type`**: Checks the type of a variable (e.g., `string`, `number`, `boolean`).
- **`match schema`**: Validates data against an [ajv](https://www.npmjs.com/package/ajv) schema, which is useful for complex object validation.

## Test

```
To run the test suite for this package, use the following command:

```bash
npm run test
```

## License

This project is licensed under the MIT License.