Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom constraint validation (setCustomValidity) #928

Open
blm768 opened this issue May 17, 2024 · 1 comment
Open

Support custom constraint validation (setCustomValidity) #928

blm768 opened this issue May 17, 2024 · 1 comment
Labels
feature A new feature

Comments

@blm768
Copy link
Contributor

blm768 commented May 17, 2024

Currently, Oruga provides mechanisms to enable HTML constraint validation, and it even provides a way to override the browser's validation message when the input is invalid (via the validationMessage prop). However, this validation message only appears if the element fails a native constraint validation check, and it only applies to the messages that Oruga shows; the element's own constraint validation state is unaffected.

It would be convenient to have an officially supported way to call setCustomValidity on Oruga's form control elements. This might either replace or supplement the current validationMessage prop. Just passing a string would likely be sufficient, although I've run into race conditions when trying to update a string prop right before submitting a form, so for that use case, we might need some mechanism to either make the call to setCustomValidity happen faster (e.g. by passing a validation function and attaching a flush: "sync" watcher) or provide an event for which we can wait so we know that constraint validation is in the expected state.

We'd probably also need to hook into the logic that propagates validation messages up to the parent field; any changes in the validation message probably should trigger a call to checkHtml5Validity (perhaps excepting cases where the field is currently focused and was previously valid, as it's less annoying to wait for the user to complete their input before displaying a message).

@blm768
Copy link
Contributor Author

blm768 commented May 17, 2024

[We] might need some mechanism to either make the call to setCustomValidity happen faster (e.g. by passing a validation function and attaching a flush: "sync" watcher) or provide an event for which we can wait so we know that constraint validation is in the expected state.

I suppose this isn't a terrible use case for nextTick.

@mlmoravek mlmoravek added the feature A new feature label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

2 participants