-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
Description
Background:
Input validation is a critical piece of any framework. To avoid reinventing the wheel, we can leverage existing validators like Axe Validator and Simple Body Validator. The idea is to use both as they are the closest thing to Illuminate/Validation:
- Axe Validator for its expressive rules.
- Simple Body Validator as fallback or extension when one lacks rules the other provides.
This will create a flexible validation layer that ensures broad coverage of validation rules and extensibility.
Scope:
- Validation will be its own package:
@h3ravel/validation. - The first consumer of this package will be
@h3ravel/http(for request validation).
Tasks:
- Create new package
@h3ravel/validationat framework/packages. - Add adapters for Axe Validator and Simple Body Validator.
- Create unified API surface (
Validator.make(data, rules).passes()etc.). - Allow rules to be delegated to Axe or Simple Body Validator depending on support.
- Implement error formatting to standardize validation errors (consistent JSON).
- Integrate validation into
@h3ravel/httprequest lifecycle (Request.validate(rules)helper). - Add unit tests for core validator functions.
- Add integration tests inside
@h3ravel/http. - Document how to define rules, run validation, and handle errors in the website repo's guide directory.
Acceptance criteria:
- Developers can use
await request.validate(rules)inside controllers. - Rules not available in one validator should fallback to the other.
- Validation errors have a consistent format across the framework.
- Tests demonstrate both validators working via the unified API.
Difficulty: medium–large