-
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
Add rule "Age" to validation. #150
Conversation
Missing |
Hmn, there is a merge commit on the pull request. Could you do a |
Ping |
Any reason why you closed this? I see some confusion on the commits, If I were you I would:
PS: You may need to create another pull request for issue 190, since you are -apparently- using the same branch for both issues. |
@augustohp what's missing here yet? |
I'm sorry by our late. @malukenho, can you please rebase with our current master an update documentation (README.md and Validator docblocks)? |
|
||
} elseif (!is_string($input) || (is_null($this->format) && false === strtotime($input))) { | ||
return false; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid to use else
.
Instead of adding a MaximumAge rule, this creates the Age rule which incorporates both rules: minimum and maximum age. Maximum age is optional.
Fixup this commit.
This needs a fix, the "format" parameters accepted by "minimumAge" rule is not supported by the new validator. It was supposed to be compatible and do the exactly same thing as "minimumAge". It would be cool to keep the same API as the "minimumAge", example: <?php // As it was before v::minimumAge(18, 'Y-m-d')->validate('1990-01-01'); // true // Needs to work that way v::age(18, 'Y-m-d')->validate('1990-01-01'); // true v::age(18, 65, 'Y-m-d')->validate('1990-01-01'); //true ?> It could work that way as the `format` will always be something acceptable by `strtotime()` function. And an `age` (an small integer) can also be a string (Ex: "18") but is not a valid format. So, if the second parameter is given, and is not an `is_numeric()`, it is a format.
|
||
use DateTime; | ||
|
||
class AgeTest extends \PHPUnit_Framework_TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong file name, also wrong path, it must be tests/Rules/AgeTest.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fail, that need to be removed
@malukenho, I'm sorry to make you change it again, but we decided to keep BC between minor versions, so just let |
@malukenho, is there any progress on that issue? |
I could look into this if you like and get it fixed up. Unless there is something else you would rather have me work on. |
If @malukenho wants to pass this to another one I'm ok with that, let's just wait for his answer. |
@AndyWendt, since @malukenho didn't answer our question and there are 21 days since the last interaction, I'd be glad if you finish it. |
Add "Age" rule in favor of "MinimumAge".
Age rule works pretty much the same way “minimumAge”
worked but it optionally accepts a maximum age as second
argument.
See #103.
Blockers for merge
age
rule on README.age
rule on Validator docblocs.minimumAge
rule from Validator docblocs.minimumAge
(point deprecation in favor ofage
).age
compatible withminimumAge
.