Skip to content

Feat/rule attributes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Feat/rule attributes #1

wants to merge 5 commits into from

Conversation

gwillz
Copy link
Collaborator

@gwillz gwillz commented Nov 2, 2022

Some seriously magical stuff. Instead of defining rules in the rules() method, this instead puts the rules directly next to their respective property definitions.

Such as:

public MyModel
{
    /** @var string */
    #[Rule('required')]
    #[Rule('email')]
    public string $address;
}

Calling ->validate() or using the AttributesValidator class can then process these into a ValidationException or errors array.

This supports PHP 7 environments with the @rule doc tag.

Notes:

  • Unsure about calling it a Rule - should it be ValidationRule or Validate ?

@gwillz gwillz force-pushed the feat/rule-attributes branch 2 times, most recently from a325296 to a260f43 Compare November 3, 2022 07:12
@gwillz gwillz marked this pull request as ready for review November 4, 2022 01:54
@gwillz gwillz force-pushed the feat/rule-attributes branch from a260f43 to c6f78ac Compare November 4, 2022 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant