You are right, those are two different types of validation.
One is performed client-side, and it's up to the widget itself to perform that validation in its onChange()
function.
Some built-in validation attributes (e.g. [Required]
) pass settings on to the editor widget, so that it knows what to validate.
If the editor widget doesn't know about the server-side validation (for example custom validation attributes or IValidate<T>
implementations) it will simply accept the value, allowing it to pass to the server.
Since blurring results in a content save, that triggers the server-side validation, which includes all validation attributes and IValidate<T>
logic. If this validation fails, the UI will display the validation error message(s) through that little red circle.
If you have to get your custom validation logic into the UI, you could:
onChange()
method to perform custom validation client-side, potentially based on validation settings passed through an associated EditorDescriptor
to let the editor widget know what to validate, for example based on properties on custom validation attributes
In Optimizely there seems to be some specific validation code triggered for each property as they are blurred/unfocused. The property is highlighted with red and gets an error message popup next to it.
This is different from the validation done when trying to publish invalid content. In this case no property is highlighted and you just get the red little clickable circle next to the publish button.
Is there a way to trigger the first type of validation for all properties when publishing or at any other time? This would immensely improve error message handling for our editors.