Skip to content

Commit 985f9ec

Browse files
committed
Explain built-in validation, polish KBs and links
1 parent ad05224 commit 985f9ec

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#note-validation
22
>note The Telerik Blazor validation tools provide a way to display different types of validation messages. The main benefit is consistent styling with all other Telerik Blazor components. The validation tools do not expose API or settings for specific validation logic. You should configure the desired standard or custom validation separately, and then use our UI components to display messages to the user.
33
#end
4+
5+
#note-telerik-role-in-validation
6+
> The Telerik components for Blazor do not perform the actual validation of the model. Validation is managed by the [`EditContext`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.editcontext). The role of the Telerik components is to call `EditContext` methods, subscribe to `EditContext` events, retrieve validation messages, and display them. If a validation scenario does not work as expected, check the behavior in a standard Blazor `<EditForm>` to verify if the issue is related to the Telerik components.
7+
#end

components/form/validation.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ When you provide an `EditContext` to the form, you can use its [`EnableDataAnnot
6262

6363
@[template](/_contentTemplates/common/form-validation.md#note-validation)
6464

65+
@[template](/_contentTemplates/common/form-validation.md#note-telerik-role-in-validation)
66+
6567
## Validation Message Type
6668

6769
With the `ValidationMessageType` parameter of the Telerik Form for Blazor you can customize the way the validation messages are presented to the user. This setting accepts a member of the `FormValidationMessageType` enum:
@@ -272,4 +274,5 @@ You can use third-party validation libraries that integrate with the standard `E
272274

273275
## See Also
274276

275-
* [Use Custom Validation in the Form]({%slug validation-kb-custom-dataannotations-validator%})
277+
* [Custom Form `DataAnnotations` Validation]({%slug validation-kb-custom-dataannotations-validator%})
278+
* [Conditional Form Validation Options]({%slug form-kb-conditional-validation%})

components/grid/editing/validation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ You can validate the Grid with any validator that uses the `EditContext`. To cha
315315
}
316316
`````
317317
318+
@[template](/_contentTemplates/common/form-validation.md#note-telerik-role-in-validation)
319+
318320
## See Also
319321
320322
* [Grid Editing]({%slug components/grid/editing/overview%})
321-
* [Use Custom Validation in the Grid]({%slug validation-kb-custom-dataannotations-validator%})
323+
* [Custom Grid `DataAnnotations` Validation]({%slug validation-kb-custom-dataannotations-validator%})

knowledge-base/form-conditional-validation.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The **TelerikForm** supports any [validator that is compatible with the Blazor E
4040
* Perform custom validation in the [Form's `OnSubmit` event]({%slug form-events%}#onsubmit).
4141
* Implement [remote (server-side) custom validation](https://github.com/telerik/blazor-ui/tree/master/form/remote-validation).
4242
* Use [`FormItem` Templates]({%slug form-formitems-template%}). Subscribe to the **change** handlers of the field editors to execute custom logic, show notifications, etc.
43-
* Implement a [conditional `DataAnnotation` attribute](https://stackoverflow.com/questions/26354853/conditionally-required-property-using-data-annotations). To see inline error messages next to the field editor, use the [`ValidationResult` overload that passes a **field name**](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.validationresult.-ctor?view=net-6.0#system-componentmodel-dataannotations-validationresult-ctor(system-string-system-collections-generic-ienumerable((system-string)))). In this way the form validator will know which field has failed validation.
43+
* Implement a [custom conditional `DataAnnotations` attribute]({%slug validation-kb-custom-dataannotations-validator%}). To see inline error messages next to the field editor, return the [`ValidationResult` overload that accepts the invalid field name(s)](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.validationresult). In this way the form validator will know which field has failed validation.
4444

4545
<div class="skip-repl"></div>
4646

@@ -49,6 +49,10 @@ The **TelerikForm** supports any [validator that is compatible with the Blazor E
4949
new List<string> { validationContext.MemberName });
5050
````
5151

52+
@[template](/_contentTemplates/common/form-validation.md#note-telerik-role-in-validation)
53+
5254
## See Also
5355

56+
* [Custom `DataAnnotations` Validation]({%slug validation-kb-custom-dataannotations-validator%})
57+
* [Fluent Validation]({%slug form-validation%}#fluent-validation)
5458
* [Live Demo: DateRangePicker Custom DataAnnotation Attribute](https://demos.telerik.com/blazor-ui/daterangepicker/validation)

knowledge-base/validation-custom-dataannotations-validator.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This KB answers the following questions:
4343
1. Return a `ValidationResult` that includes the failing field name(s) as a second argument of type `IEnumerable<string>`. This step is crucial in order to apply invalid state to the respective input component and display an inline validation message next to it.
4444
1. (optional) Override the `FormatErrorMessage` method to provide a custom validation message.
4545

46-
> Creating a custom DataAnnotations validator does not involve Telerik APIs and is outside the Telerik support scope. The following implementation is just an example that shows that Telerik Blazor components can work with a custom validator. The exact validator implementation depends on the specific requirements and can vary.
46+
> Creating a custom `DataAnnotations` validator does not involve Telerik APIs and is outside the Telerik support scope. The following implementation is just an example that shows that Telerik Blazor components can work with a custom validator. The exact validator implementation [depends on the specific requirements and can vary](https://stackoverflow.com/questions/26354853/conditionally-required-property-using-data-annotations).
4747
4848
>caption Use custom conditional required DataAnnotations validator with Telerik components for Blazor
4949
@@ -209,8 +209,11 @@ This KB answers the following questions:
209209
}
210210
````
211211

212+
@[template](/_contentTemplates/common/form-validation.md#note-telerik-role-in-validation)
213+
212214
## See Also
213215

216+
* [Conditional Form Validation Options]({%slug form-kb-conditional-validation%})
214217
* [Form Validation]({%slug form-validation%})
215-
* [Grid Validation]({%slug grid-editing-validation%}})
216-
* [Validation Tools Overview]({%slug validation-tools-overview%}})
218+
* [Grid Validation]({%slug grid-editing-validation%})
219+
* [Validation Tools Overview]({%slug validation-tools-overview%})

0 commit comments

Comments
 (0)