|
2 | 2 |
|
3 | 3 | A powerful and flexible request validation library for Node.js applications, built with TypeScript. This library provides a comprehensive set of validation rules and supports both synchronous and asynchronous validation. |
4 | 4 |
|
| 5 | +[](https://www.npmjs.com/package/@th3hero/request-validator) |
| 6 | +[](https://opensource.org/licenses/MIT) |
| 7 | + |
5 | 8 | ## Table of Contents |
6 | 9 | - [Features](#features) |
7 | 10 | - [Installation](#installation) |
@@ -122,6 +125,9 @@ app.post('/upload', async (req: Request, res) => { |
122 | 125 | | `required` | Field must be present and not empty | `username: 'required'` | "username is required" | |
123 | 126 | | `nullable` | Field can be null or undefined | `middle_name: 'nullable'` | - | |
124 | 127 | | `not-empty` | Field cannot be empty | `description: 'not-empty'` | "description cannot be empty" | |
| 128 | +| `numeric` | Field must be a number | `age: 'numeric'` | "age must be a number" | |
| 129 | +| `confirmed` | Field must have a matching confirmation field | `password: 'confirmed'` | "password must be confirmed" | |
| 130 | +| `digits:length` | Field must contain exactly the specified number of digits | `phone: 'digits:10'` | "phone must be exactly 10 digits" | |
125 | 131 |
|
126 | 132 | ### String Rules |
127 | 133 |
|
@@ -152,6 +158,7 @@ app.post('/upload', async (req: Request, res) => { |
152 | 158 | |------|-------------|---------|---------------| |
153 | 159 | | `file` | Must be a file upload | `profile_picture: 'file'` | "profile_picture is required" | |
154 | 160 | | `mimetype:types` | Valid MIME types | `avatar: 'mimetype:image/jpeg,image/png'` | "Invalid file format for avatar. Supported media types are image/jpeg, image/png" | |
| 161 | +| `max_size:size` | File size must not exceed the specified size | `avatar: 'max_size:2048'` | "avatar file size must not exceed 2048 bytes" | |
155 | 162 |
|
156 | 163 | ### Database Rules |
157 | 164 |
|
@@ -431,4 +438,8 @@ npm run test:coverage |
431 | 438 |
|
432 | 439 | # Run tests in watch mode |
433 | 440 | npm run test:watch |
434 | | -``` |
| 441 | +``` |
| 442 | + |
| 443 | +## License |
| 444 | + |
| 445 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments