@h3ravel/validation 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/env.d.ts +1 -0
- package/dist/index.cjs +648 -0
- package/dist/index.d.ts +340 -0
- package/dist/index.js +642 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 h3ravel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://h3ravel.toneflix.net" target="_blank">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/h3ravel/assets/refs/heads/main/logo-full.svg" width="200" alt="H3ravel Logo">
|
|
4
|
+
</a>
|
|
5
|
+
<h1 align="center"><a href="https://h3ravel.toneflix.net/guide/validation">H3ravel Validation</a></h1>
|
|
6
|
+
|
|
7
|
+
[![Framework][ix]][lx]
|
|
8
|
+
[![Validation Package Version][i1]][l1]
|
|
9
|
+
[![Downloads][d1]][l1]
|
|
10
|
+
[![Tests][tei]][tel]
|
|
11
|
+
[![License][lini]][linl]
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
# About H3ravel/validation
|
|
16
|
+
|
|
17
|
+
Lightweight validation library providing expressive rule-based validation for requests, data objects, and custom logic for [H3ravel](https://h3ravel.toneflix.net) applications.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @h3ravel/validation
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Rule-based validation — Supports common rules like required, min, max, email, url, numeric, boolean, in, regex, etc.
|
|
28
|
+
- Nested data validation — Dot notation for nested objects (user.email, items.\*.price).
|
|
29
|
+
- Custom error messages — Per-rule and per-field message overrides.
|
|
30
|
+
- Batch validation — Validate multiple datasets or groups in one call.
|
|
31
|
+
- Conditional validation — Rules that only apply when other fields meet conditions (required_if, sometimes, exclude_unless).
|
|
32
|
+
- Implicit rules — Rules that run even when attributes are missing (e.g., accepted, required).
|
|
33
|
+
|
|
34
|
+
- Custom rules — Define user-provided validation rules as functions or classes.
|
|
35
|
+
- Async rules — Support for async validation (e.g., checking uniqueness in a database).
|
|
36
|
+
- Attribute sanitization — Optional transformation (e.g., trimming, normalizing case) before validation.
|
|
37
|
+
- Dynamic rule sets — Rules can be generated at runtime (e.g., based on user roles).
|
|
38
|
+
- Dependent rules — Rules that reference other fields dynamically.
|
|
39
|
+
|
|
40
|
+
- Localized error messages — Built-in support for localization and i18n message templates.
|
|
41
|
+
- Structured errors — Validation errors returned as structured objects or flat key–message pairs.
|
|
42
|
+
- Fail-fast mode — Option to stop at the first failure or collect all errors.
|
|
43
|
+
- Human-readable summaries — Helper for formatting readable validation reports.
|
|
44
|
+
|
|
45
|
+
- TypeScript-first design — Full type inference for rules, messages, and validated data.
|
|
46
|
+
- Chainable API — Optional fluent syntax for building validators.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
## Contributing
|
|
51
|
+
|
|
52
|
+
Thank you for considering contributing to the H3ravel framework! The [Contribution Guide](https://h3ravel.toneflix.net/contributing) can be found in the H3ravel documentation and will provide you with all the information you need to get started.
|
|
53
|
+
|
|
54
|
+
## Code of Conduct
|
|
55
|
+
|
|
56
|
+
In order to ensure that the H3ravel community is welcoming to all, please review and abide by the [Code of Conduct](#).
|
|
57
|
+
|
|
58
|
+
## Security Vulnerabilities
|
|
59
|
+
|
|
60
|
+
If you discover a security vulnerability within H3ravel, please send an e-mail to Legacy via hamzas.legacy@toneflix.ng. All security vulnerabilities will be promptly addressed.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
The H3ravel framework is open-sourced software licensed under the [MIT license](LICENSE).
|
|
65
|
+
|
|
66
|
+
[ix]: https://img.shields.io/npm/v/%40h3ravel%2Fcore?style=flat-square&label=Framework&color=%230970ce
|
|
67
|
+
[lx]: https://www.npmjs.com/package/@h3ravel/core
|
|
68
|
+
[i1]: https://img.shields.io/npm/v/%40h3ravel%2Fvalidation?style=flat-square&label=@h3ravel/validation&color=%230970ce
|
|
69
|
+
[l1]: https://www.npmjs.com/package/@h3ravel/validation
|
|
70
|
+
[d1]: https://img.shields.io/npm/dt/%40h3ravel%2Fvalidation?style=flat-square&label=Downloads&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40h3ravel%2Fvalidation
|
|
71
|
+
[linl]: https://github.com/h3ravel/framework/blob/main/LICENSE
|
|
72
|
+
[lini]: https://img.shields.io/github/license/h3ravel/framework
|
|
73
|
+
[tel]: https://github.com/h3ravel/framework/actions/workflows/test.yml
|
|
74
|
+
[tei]: https://github.com/h3ravel/framework/actions/workflows/test.yml/badge.svg
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="../../foundation/src/app.globals.d.ts" />
|