displaying field level validation errors from the backend
Hi,
My backend returns validation structured validation errors on post or put, with field level error information for example:
How can I get the error for the
name
field to display next to the name
field in refine. Is there a specific exception error structure I need to use?21 Replies
metropolitan-bronze•2y ago
Hi @noam.honig,
here is a brief explanation in docs.
https://refine.dev/docs/api-reference/core/hooks/useForm/#how-can-invalidate-other-resources
extended-salmon•2y ago
Thanks for getting back to me, I've read the article and I can't find in it what I want looking for.
I was hoping for a structure of an exception I as a
dataProvider
can throw in the create
or update
that'll be handled by refine to display the error correctly next to the field.metropolitan-bronze•2y ago
@noam.honig Im so sorry. I sent you wrong link 😦
https://refine.dev/docs/api-reference/core/providers/data-provider/#error-format this is the correct one
extended-salmon•2y ago
Thanks for that. In that error, how do I specify the exact error text I want to display next to each field?
Something like:
metropolitan-bronze•2y ago
Which form library u are using ?
extended-salmon•2y ago
I'm using the default one used in the tutorial
metropolitan-bronze•2y ago
which tutorial ?
extended-salmon•2y ago
metropolitan-bronze•2y ago
you can write custom form validation and error message like this
https://refine.dev/docs/advanced-tutorials/forms/custom-form-validation/
extended-salmon•2y ago
I see - I was hoping for something built in refine that standardizes that as well
metropolitan-bronze•2y ago
🙏 we will release refine 4 in 1 or 2 month. we will definitely consider this
Hi @noam.honig, We discussed in the core team. We think your point is really valuable. Thank you 🙏
Do you wanna open feature request on Github ? If you open, we try to speed things up.
extended-salmon•2y ago
Sounds good
Remult looks great, congrats 🙂
Are you creating a dataprovider?
extended-salmon•2y ago
Hi @Omer, yes I'm creating a data provider, it seems fairly simple and powerful
@Omer Since you mentioned remult, I would like to ask a follow-up question if that's ok.
In remult I have a lot of metadata around the entities (field types, captions, validations etc...) This opens up the opportunity to create a powerful inferer that'll be based on entity metadata rather than JSON results.
Is there a simple api for me to use to provide metadata to the refine inferer or do I need to create multiple inferers of my own?
@aliemirs can you help?