mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(FormField): display multiple errors
Adds the `errors` and `maxErrors` properties to the FormField component which allows to display multiple errors. The `maxErrors` prop is used to limit the number of errors displayed and defaults to 1 for backward compatibility. This change is compatible with the `Form` component error's too. Resolves #2389
This commit is contained in:
@@ -68,6 +68,10 @@ describe('FormField', () => {
|
||||
['with required', { props: { label: 'Username', required: true } }],
|
||||
['with help', { props: { help: 'Username must be unique' } }],
|
||||
['with error', { props: { error: 'Username is already taken' } }],
|
||||
['with multiple errors', { props: { errors: ['Username is already taken', 'This should not be visible'] } }],
|
||||
['with maxErrors', { props: { maxErrors: 2, errors: ['Username is already taken', 'This should be visible'] } }],
|
||||
['with maxErrors negative', { props: { maxErrors: -1, errors: ['Username is already taken', 'This should be visible', 'This should be visible'] } }],
|
||||
['with maxErrors false', { props: { maxErrors: false, errors: ['Username is already taken', 'This should be visible', 'This should be visible'] } }],
|
||||
['with hint', { props: { hint: 'Use letters, numbers, and special characters' } }],
|
||||
...sizes.map((size: string) => [`with size ${size}`, { props: { label: 'Username', description: 'Enter your username', size } }]),
|
||||
['with as', { props: { as: 'section' } }],
|
||||
|
||||
Reference in New Issue
Block a user