glideapps / glideapps/glide-data-grid
Allow showing a validation message with `validateCell`
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
Input validation via `validateCell` is quite useful. But it can also be confusing for the user since there is no native way of showing why the input is invalid. I think it would currently require implementing a dedicated cell overlay editor to show such a message.
Maybe we can extend some of the native cell overlay editors to support showing a message explaining why an input is invalid.
Proposed API:
```
readonly validateCell?: (cell: Item, newValue: EditableGridCell) => string | boolean | EditableGridCell;
```
If a string is returned, it is interpreted as a validation message explaining the constraint. Thereby, the overlay editor needs to somehow show this to the user. Maybe it is possible to use the [`setCustomValidity`](https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_combining_several_fields_postal_code_validation) functionality of native HTML input elements for this. E.g. see [this example](https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_combining_several_fields_postal_code_validation):
Contributor guide
Assessment
This issue has not been assessed yet.