Skip to content

Feat: Implement validation system #32

@3m1n3nc3

Description

@3m1n3nc3

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/validation at 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/http request 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions