Validation: problem with nullValue()
I have a class that has a property, end_price, that I validate like this:
v::attribute('end_price', v::oneOf(v::nullValue(),v::numeric()->positive()))
if I set this property to and empty string and then do ->assert($this) it passes. I have tried this with 9.2 and 9.3.
what am I missing?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20 (7 by maintainers)
@asperon I think your problem is that you are passing an object to
assert()instead of the result, which is akin to doingassert(new StdClass)which always equates totrue.Try the following instead:
Also you don’t need to chain
notEmpty()tonullValue()see description:Hope that helps…