Skip to content
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

Validation rules composition #158

Closed
System-Glitch opened this issue Aug 4, 2021 · 0 comments
Closed

Validation rules composition #158

System-Glitch opened this issue Aug 4, 2021 · 0 comments
Assignees
Labels
enhancement Enhancement of existing feature

Comments

@System-Glitch
Copy link
Member

Proposal

Sometimes it could be handy to be able to use another rule set inside a larger rule set by using composition. Example:

CreateUserRequest = validation.RuleSet{
    "email": {"required", "email"},
    "password": {"required", "min:6"},
}

CreateManyUsersRequest = validation.RuleSet{
    "users": {"required", "array:object"},
    "users[]": CreateUserRequest,
}

Note: could use an interface so both types ([]string{} and RuleSet) can be used as a value inside a RuleSet. Don't forget about alternative syntax too!

Possible drawbacks

None.

@System-Glitch System-Glitch added enhancement Enhancement of existing feature v4 labels Aug 4, 2021
@System-Glitch System-Glitch self-assigned this Aug 4, 2021
@System-Glitch System-Glitch mentioned this issue Jan 14, 2022
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

1 participant