Form validation
Validation is achieved by applying isInvalid and optionally error props onto the EuiForm or EuiFormRow components. Errors are optional and are passed as an array in case you need to list more than one. You can also hide the callout by passing invalidCallout=“none“
Usage
Validation error text
Validation messages are needed when the user input differs from what the system expects and enforces:
- Required fields that are still blank.
- Invalid values, for one or several reasons (forbidden characters, formatting, duplicate).
Use clear language that helps users understand what they have to do.
Do: Use a simple, minimalist format for a required field.
Do: Tell users what happened and how to fix it.
Do: Be as precise as possible to describe the problem.
Props
EuiForm
Prop | Description and type | Default value |
|---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop component# | Description and type Which HTML element to render "div" | "form" | Default value div |
Prop isInvalid# | Description and type Type: boolean | Default value |
Prop error# | Description and type Type: ReactNode | ReactNode[] | Default value |
Prop invalidCallout# | Description and type Where to display the callout with the list of errors "none" | "above" | Default value above |
Prop fullWidth# | Description and type When set to boolean | Default value false |
Prop ref# | Description and type Allows getting a ref to the component instance. LegacyRef<HTMLElement> | Default value |