Types

FormState


FormState

FormState is an object containing the following values. Depending on your subscription when calling form.subscribe(), some of the values may not be present.

active

string

The name of the currently active field. undefined if none are active.

dirty

boolean

true if the form values are different from the values it was initialized with. false otherwise. Comparison is done with shallow-equals.

dirtyFields

{ [string]: boolean }

An object full of booleans, with a value of true for each dirty field. Pristine fields will not appear in this object. Note that this is a flat object, so if your field name is addresses.shipping.street, the dirty value for that field will be available under dirty['addresses.shipping.street'].

dirtyFieldsSinceLastSubmit

{ [string]: boolean }

An object full of booleans, with a value of true for each field that has a different value from the one when the form was last submitted. Pristine (since last submit) fields will not appear in this object. Note that this is a flat object, so if your field name is addresses.shipping.street, the dirtySinceLastSubmit value for that field will be available under dirty['addresses.shipping.street'].

dirtySinceLastSubmit

boolean

true if the form values are different from the values it was last submitted with. false otherwise. Comparison is done with shallow-equals.

error

any

The whole-form error returned by a validation function under the FORM_ERROR key.

errors

Object

An object containing all the current validation errors. The shape will match the shape of the form's values.

hasSubmitErrors

boolean

true when the form currently has submit errors. Useful for distinguishing why invalid is true.

hasValidationErrors

boolean

true when the form currently has validation errors. Useful for distinguishing why invalid is true. For example, if your form is invalid because of a submit error, you might also want to disable the submit button if user's changes to fix the submit errors causes the form to have sync validation errors.

initialValues

FormValues

The values the form was initialized with. undefined if the form was never initialized.

invalid

boolean

true if any of the fields or the form has a validation or submission error. false otherwise. Note that a form can be invalid even if the errors do not belong to any currently registered fields.

modified

{ [string]: boolean }

An object full of booleans, with a boolean value for each field name denoting whether that field is modified or not. Note that this is a flat object, so if your field name is addresses.shipping.street, the modified value for that field will be available under modified['addresses.shipping.street'].

pristine

boolean

true if the form values are the same as the initial values. false otherwise. Comparison is done with shallow-equals.

submitError

any

The whole-form submission error returned by onSubmit under the FORM_ERROR key.

submitErrors

Object

An object containing all the current submission errors. The shape will match the shape of the form's values.

submitFailed

boolean

true if the form was submitted, but the submission failed with submission errors. false otherwise.

submitSucceeded

boolean

true if the form was successfully submitted. false otherwise.

submitting

boolean

true if the form is currently being submitted asynchronously. false otherwise.

touched

{ [string]: boolean }

An object full of booleans, with a boolean value for each field name denoting whether that field is touched or not. Note that this is a flat object, so if your field name is addresses.shipping.street, the touched value for that field will be available under touched['addresses.shipping.street'].

valid

boolean

true if neither the form nor any of its fields has a validation or submission error. false otherwise. Note that a form can be invalid even if the errors do not belong to any currently registered fields.

validating

boolean

true if the form is currently being validated asynchronously. false otherwise.

values

FormValues

The current values of the form.

visited

{ [string]: boolean }

An object full of booleans, with a boolean value for each field name denoting whether that field is visited or not. Note that this is a flat object, so if your field name is addresses.shipping.street, the visited value for that field will be available under visited['addresses.shipping.street'].