Ant Design. How to set form field error message dynamically?

zheng li picture zheng li · Nov 12, 2017 · Viewed 20.4k times · Source

A form field has many asynchronous check rules, since a composited api can check these rules one time by return different result, i do not want to fire so many api request.

Answer

Aseem Gautam picture Aseem Gautam · Nov 13, 2017

Use form.setFields

Syntax

Function({ fieldName: { value: any, errors: Error } })

Example from here -

this.props.form.setFields({
  user: {
    value: values.user,
    errors: [new Error('forbid ha')],
  },
});