Inconsistent behavior of the Required validation rules (incl. unless, if, and other related Required rules) #511
davidkvasnovsky
started this conversation in
General
Replies: 1 comment
-
Yeah we have some problems on that front with the attributes, using custom rules is the solution for now or see: #500. Someone is already trying to fix it for optional over there. It should probably also happen for nullable data objects. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's assume we have a Data object, where the
properties
field (for example, a JSON column casted as Data) is both nullable and required only when the User role differs from Customer.Now when we try to create
CreateUserData
from the request with the following payload (without theproperties
field):CreateUserController:
Everything works, and a new instance is created with the following response:
But I think that the expected behavior should be that it won't pass validation. If we add validation rules manually:
It behaves as expected and throws a validation error.
Same applies for all related Required validation rules (
Required
,Required Unless
,Required If
...).Edited: I just recently found out that the same bug applies for
#[Rule]
attribute.Beta Was this translation helpful? Give feedback.
All reactions