-
Notifications
You must be signed in to change notification settings - Fork 167
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
Simplify the Validator.validate() return type #8552
Comments
Haprog
added a commit
that referenced
this issue
Jun 22, 2020
- ValidationCallback may now return a single ValidationResult or an array of ValidationResult objects which don't need to specify the "value" or "validator" properties which were needed previously when ValueError was used in the return type. - ValidationResult may contain an optional "message" property for overriding the default error message (coming from validator) for a specific property. - ValueError now also directly has a "message" property so it's slightly simpler to get the error messages when working with a list of errors. - Update flow-client tsconfig to allow using Array.flat() etc. Fixes #8552
platosha
pushed a commit
that referenced
this issue
Jun 23, 2020
* Simplify ValidationCallback return type - ValidationCallback may now return a single ValidationResult or an array of ValidationResult objects which don't need to specify the "value" or "validator" properties which were needed previously when ValueError was used in the return type. - ValidationResult may contain an optional "message" property for overriding the default error message (coming from validator) for a specific property. - ValueError now also directly has a "message" property so it's slightly simpler to get the error messages when working with a list of errors. - Update flow-client tsconfig to allow using Array.flat() etc. Fixes #8552 * Add Binder as a parameter to ValidationCallback * Fix linter errors
vlukashov
pushed a commit
to vaadin/flow-and-components-documentation
that referenced
this issue
Jun 29, 2020
Highlight server-side validation as the primary way to validate the user input. Present client-side validation as a UX optimization. Provide a complete example for adding a custom validator (both server-side and client-side). Introduce JSR-380 instead of assuming readers know what it is. Make the example more realistic. Also update the docs after fixing vaadin/flow#8551 and vaadin/flow#8552 Fixes #1291 Fixes #1292
platosha
added a commit
to vaadin/flow-and-components-documentation
that referenced
this issue
Jun 30, 2020
* fix: improve client-side validation docs Highlight server-side validation as the primary way to validate the user input. Present client-side validation as a UX optimization. Provide a complete example for adding a custom validator (both server-side and client-side). Introduce JSR-380 instead of assuming readers know what it is. Make the example more realistic. Also update the docs after fixing vaadin/flow#8551 and vaadin/flow#8552 Fixes #1291 Fixes #1292 * reveiew comments - move the 'note' block from the beginning to the point when custom client-side validators are introduced - move the 'required field' section to under the custom validators section Co-authored-by: Anton Platonov <anton@vaadin.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The return type of the
validate()
method in record-level validators should be more intuitive to use (should not require including boilerplate / unnecessary properties).DoD:
return { property: model.password }
return [{ property: model.password }, { property: model.repeatPassword }]
(in this case the validator's default message it linked to the first property in the array)[{ property: model.password }, { property: model.repeatPassword, message: 'please check that you've repeated the password exactly as it's typed in the field above ^' }]
return false
return true
orreturn []
both are treated as 'validation passed without errors' (the recommended way in all our examples isreturn true
).Extra:
It’s not easy to access the model inside the validator function => add
binder
as the second parameter to the validator callback:validate: async (value, binder) => { ... }
The text was updated successfully, but these errors were encountered: