getErrors

Returns the current errors of the form fields or a field array.

// Get errors of each field
const errors = getErrors(form, options);

// Get errors of a field array
const errors = getErrors(form, name, options);

// Get errors of specific fields
const errors = getErrors(form, names, options);

Parameters

  • form FormStore
  • names string
  • names string[]
  • options object = {}
    • shouldActive boolean = true
    • shouldTouched boolean = false
    • shouldDirty boolean = false

Explanation

Besides the names of fields, you can also specify the name of a field array under names to get the value of each contained field.

By default, only the errors of fields that are currently active are returned. If you want errors of inactive fields to be returned as well, you can set shouldActive to false.

By default, the errors of fields that are not touched and not dirty are also returned. If you want only the errors of the touched and/or dirty fields to be returned, you can set shouldTouched and/or shouldDirty to true.

shouldActive, shouldTouched and shouldDirty act like a kind of filter and can be combined with each other.

Return