-
Notifications
You must be signed in to change notification settings - Fork 772
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
Create age
validator (Deprecates minimumAge
)
#103
Comments
Actually there is some legal complications on letting people below the legal age of the country signing for some services, but never heard of possible limitations for maximum age. I do believe that if there are applications for that, than we should probably consider adding it or accept a pull request :) @Petah Do you have some examples of use cases for that validator? |
@augustohp we have had problems with people submitting an age in the incorrect format, and/or with typos causing us to require implementing validation rules around it. Also when asking for a date of birth, expecting the user to be under 120 years should be an acceptable limitation. I will look at implementing this based off the minimumAge validator and sending you a pull request. |
@Petah I think that could be a good idea to create two rules, if you can: |
We already have
The minimumAge validator has a single difference from Perhaps an
The string containing the sings + and - can be directly reused in a strtotime operation inside the validation implementation, we just need to append the "years" suffix:
Thoughts? |
+0 |
ageDifference? |
ageDiff ? |
No, I thinks age is better. |
My suggestion is to validate ages from a date of birth, something like this:
To validate numbers we can use the between validator. |
I'm not sure about the format. The same could be written like:
I believe keeping them separate is more modular. Anyway, your suggestion is by far the best. Removing the format parameter we can even make it backward-compatible with the minimumAge() validator and deprecate it. +1 for |
Nice, I've put format parameter because I was not sure that this kind of fluent validator was possible... so +1 for |
I've update the issue description to easy contributions and resume discussion until now. |
This rule is going to be available in |
This resumes the discussion happened below until @caferrari comment:
age
validation rule:v::age($min, $max=null)
.mininumAge
validation rule in favor of theage
rule.Original message (for historical purposes):
The text was updated successfully, but these errors were encountered: