Skip to content

Conversation

@arnaugiralt
Copy link
Member

This PR adds input validation to Textfield and Select components, plus other fixes:

  • Create useFieldValidation composable to validate input fields against rules
  • Implement validation in Textfield and Select components
  • Other Textfield fixes: fixed focused and label styles, added hint, fixed focus behaviour
  • Other Select fixes: fixed focused styles, added customisation to option rendering, add menuProps
  • Emit "opened" and "closed" when Menu widget is toggled
  • Add new stories for Textfield and Select

Validation works the same way as in the SPA: rules is an array of functions, and validation is only successful if the rule returns explicitly true. If the rule fails, it should return an error message string.

Example of a rule:

const isRequired = (value) => !!value || 'This field is required';

const rules = [isRequired];

I added examples of rules validation in the Storybook as well.


You can check the storybook build if you want to check it in real time, but I also attach these screenshots (already verified styles with Max Tiumin).

Some text fields: field with error, filled field, field with error and focused:
Some text fields: field with error, filled field, field with error and focused

Select, open, with an option selected:
Select, open, with an option selected

Some mix of fields:
Some mix of fields

- Create useFieldValidation composable to validate input fields against rules
- Implement validation in Textfield and Select components
- Other Textfield fixes: fixed focused and label styles, added hint, fixed focus behavior
- Other Select fixes: fixed focused styles, added customization to option rendering, add menuProps
- Emit "opened" and "closed" when Menu widget is toggled
- Add new stories for Textfield and select
@sonarqubecloud
Copy link

@nerimartinez nerimartinez merged commit 9d345e2 into master Mar 20, 2024
@nerimartinez nerimartinez deleted the feat/add-input-validation branch March 20, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants