Validation with sibling / full object data #466
Replies: 2 comments 4 replies
-
Hey @oranoran — this suggestion makes a ton of sense and would be fairly quickly doable in code. I think there are only a few things to determine here:
@DanRibbens @denolfe @oranoran what do we think? |
Beta Was this translation helpful? Give feedback.
-
Hi @oranoran — this is now deployed within |
Beta Was this translation helpful? Give feedback.
-
When evaluating whether a field should be shown in the admin panel, the
condition
function receives two arguments: the full object, and siblings of the current field. This is extremely useful and easy to use.However the
validate
function, which is equally useful, doesn't receive these. This inconsistency is probably due to the fact that this function is not part of theadmin
configuration. But regardless of the reason, this is a problem, for example in the following use case:condition
, because thecondition
function on field B receives the value of field A.condition
.validate
function on field D doesn't receive the value of field C.It might be possible to do the validation with server-side pre-update and pre-create hooks, but this feels a bit of an overkill. Why not just pass the same parameters to
validate
as those being passed tocondition
? On the server side, the depth of the passed objects maybe be determined with another parameter, or maybe even just pass the siblings for simplicity - it's still much better than the current situation.I saw there is a broader discussion of related topics in #236, but I think having a discussion that is too broad could mean that this will never get addressed... While a simpler and more limited solution, specifically for validation, could possibly be implemented rather quickly.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions