IgniteUI / igniteui-webcomponents

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
https://www.infragistics.com/products/ignite-ui-web-components
Other
113 stars 2 forks source link

Enhancing Web Components Form Validation #1195

Open Marina-L-Stoyanova opened 1 month ago

Marina-L-Stoyanova commented 1 month ago

Here is a sample that demonstrate the current way to implement Web Components form with validation: Web Components Validation

We should consider:

  1. In-Component Validation:

    Implement validation logic directly within the Web Components that can be used in a Form(igc-input, igc-textarea, igc-select and ect.). This approach encapsulates validation rules and keeps them self-contained. Validate input data as users interact with the form elements (e.g., on blur or input change events).

  2. Displaying Validation Messages:

    Show validation messages when input is invalid.

  3. Slot Considerations:

    Evaluate whether to use existing slots (like helper-text) or create a dedicated slot (e.g., validation-message) for displaying validation feedback. (Using a separate slot allows flexibility in styling and positioning validation messages.)

rkaraivanov commented 1 month ago

We should consider:

  1. In-Component Validation:

    Implement validation logic directly within the Web Components that can be used in a Form(igc-input, igc-textarea, igc-select and ect.). This approach encapsulates validation rules and keeps them self-contained.

This is already covered by the existing form associated components.

Displaying Validation Messages Slot Considerations

This definitely merits further exploration and potential integration into the library. In my opinion, dedicating a distinct slot solely for error messages seems advantageous. We'll begin to consider these aspects and aim to have a preliminary implementation shortly.