Use mapped path in error messages #198
Replies: 3 comments 3 replies
-
Hi @npatel-rmn, sorry for the late answer! This is an interesting usecase indeed. Unfortunately, the library wont be able to help you for the time being. I didn't think about this kind of usage during the development, and to be honest I currently have no idea how to fix that. I'll leave the discussion open, if I come with a solution at some point I'll keep you updated here. 😉 |
Beta Was this translation helpful? Give feedback.
-
I've hit the same hurdle. @npatel-rmn: have you written a workaround? If so, can you please enlighten us on your solution? |
Beta Was this translation helpful? Give feedback.
-
Sort of similarly, I've just ran into the issue where it will report the node path for an enum as |
Beta Was this translation helpful? Give feedback.
-
I've been toying about with Valinor for a little a bit and am really liking it so far!
I have a use case where I've hit a hurdle; I'm using the path mapping functionality on my data source because my input data is using different field names to my PHP objects:
The issue is that when Valinor reports errors on the input fields, the node names and paths referenced in the
NodeMessage
s mention the names of my PHP object (ID, startDate). I would like to report the error messages back to the client using field names it recognises (id, start_date).Is there an easy way to reverse the path mapping?
A super simple solution could be for me to
array_flip
the mapping keys and use that to transformID
toid
when looping over the error messages. However this approach breaks down when working with nested objects and path mappings. Take the example in the docs:I can't use the
towns.*.label
key verbatim, so my hope is that Valinor can help with this.Keen to hear your thoughts and thanks for the great package!
Beta Was this translation helpful? Give feedback.
All reactions