Skip to content

Feat/rule attributes - #1

Open
gwillz wants to merge 5 commits into
masterfrom
feat/rule-attributes
Open

Feat/rule attributes#1
gwillz wants to merge 5 commits into
masterfrom
feat/rule-attributes

Conversation

@gwillz

@gwillz gwillz commented Nov 2, 2022

Copy link
Copy Markdown
Collaborator

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