-
Notifications
You must be signed in to change notification settings - Fork 136
add IsCountable validator, to enforce type and count elements. #157
Conversation
Updates `Hostname` validator TLD list.
Add PHP 7.2 support, drop HHVM Conflicts: .travis.yml
- Whitespace following `function` keyword
- Uses newlines and indentation to group conditional statements
Updates the zend-session requirement to v2.8+, to ensure compatibility with PHP 7.2.
thank you for the feedback. i'll get this fixed up tonight. |
test/IsCountableTest.php
Outdated
} | ||
|
||
/** | ||
* @expectedException \Zend\Validator\Exception\RuntimeException |
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.
Please use the expectException()
method, this is the preferred way. Thanks!
test/IsCountableTest.php
Outdated
$this->sut->setMin(1); | ||
$this->sut->setMax(10); | ||
|
||
self::assertTrue($this->sut->isValid(['Foo']), json_encode($this->sut->getMessages())); |
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.
Please use $this->
instead of self::
, this is the preferred way. Thanks!
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.
@Ocramius thinks something else 😜
…max in setOptions which is used by the constructor, use getter methods instead of options field in isValid, report NOT_COUNTABLE as a validation error rather than throwing an exception, and use `$this->` instead of `self::` for assertions in test case.
thanks everyone for the review. i think i took care of everything asked. @weierophinney i chose to implement the mutex logic in setOptions because it is invoked from the constructor. my test case covers behavior of the constructor and setOptions. |
add IsCountable validator, to enforce type and count elements.
…x value Since there is no way to clear a `count`, this is the only way to ensure that behavior remains as expected when merging options from disparate sources.
@abacaphiliac I've added some commits that do the following:
I'm expecting the only test failure to be due to the hostname TLD list being out-of-date (again! those used to update more on an order of weeks or months, and now it's practically daily!); if that's the case, I can merge this. |
Thanks for this great feature, @abracaphiliac! I have merged it to develop for an upcoming 2.10.0 release (likely today or tomorrow). |
my pleasure. thank you for the assist : ) |
hi Team,
i created something like this in a private project (to enforce a countable has at least one element) but thought a more configurable version might be useful to others. what do you think?