question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server side validation example

See original GitHub issue

Could you provide server side validation, please?

I have backend-based validation according to business rules. Backend returns 442 HTTP response code as error payload with JSON key-value array, where key is the problematic field name and value - the error description.

I’ve tried to use onMutationError callback in useForm hook, there i can get errors but haven’t form ref that’s needed for setting errors according antd docs by formRef.setFields()

Also I have tried to use onFinishFailed prop in the Form component, but it isn’t called when error.

How can i set server errors to form?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
misterxcommented, Apr 6, 2022

@omeraplak Thanks, your solution is much better.

1reaction
omeraplakcommented, Apr 4, 2022

Hey @misterx , When I tried this way, I succeeded. Is there a point I missed?

const { formProps, saveButtonProps, form } = useForm<IPost>({
        onMutationError: () => {
            form?.setFields([
                {
                    name: "title",
                    errors: ["Any error!"],
                },
            ]);
        },
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Input Validation: Client-Side & Server-Side Cybersecurity ...
Server-side validation is done in the model/entity class by attaching attributes above the property declaration to dictate the data types that ...
Read more >
Input Validation on Client-Side or Server-Side? - Packetlabs
Client-side validation is visible to the user. It involves having validation on input forms through JavaScript. For example, if the input is ...
Read more >
Server Side Validation | VeeValidate
Client-side validation is meant to aid the users by providing instant feedback, so implementing both provides great user experience and reduces potential ...
Read more >
Differentiate between client side validation and server side ...
In the Server Side Validation, the input submitted by the user is being sent to the server and validated using one of server...
Read more >
Server-side validation, client-side feel - .NET Guide - JetBrains
A typical example is a user registration form. While a username may follow the client-side criteria for a valid username, newcomers won't know ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found