Skip to content

Commit 30bb773

Browse files
dimodidimodi
authored andcommitted
docs(Validation): Revamp Validation components documentation and examples
1 parent d2c96c0 commit 30bb773

File tree

4 files changed

+285
-391
lines changed

4 files changed

+285
-391
lines changed

components/validation/message.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ position: 15
1010

1111
# Telerik Validation Message for Blazor
1212

13-
The <a href = "https://www.telerik.com/blazor-ui/validation-message" target="_blank">Telerik Validation Message for Blazor</a> adds built-in styling and customization options on top of the standard [.NET ValidationMessage](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.validationmessage-1), such as [`Template`](#template) and [`Class`](#class) parameters.
13+
The [Telerik Validation Message for Blazor](https://www.telerik.com/blazor-ui/validation-message) adds built-in styling and customization options on top of the standard [.NET ValidationMessage](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.validationmessage-1), such as [`Template`](#template) and [`Class`](#class) parameters.
1414

1515
## Basics
1616

@@ -49,7 +49,7 @@ The Telerik Form [displays inline validation messages by default if validation i
4949
5050
* Use [form item templates](slug:form-formitems-template). In this case, [add the validation message in the form item template](slug:form-formitems-template#example).
5151
* Customize the validation messages, for example, change their rendering with a [validation message template](#template). In this case, add the validation message inside a [Form item template](slug:form-formitems-template#example).
52-
* Customize the placement of the validation messages in the Form, so that they are outside the Form item containers. In this case, consider a [`<FormItemsTemplate>`](slug:form-formitems-formitemstemplate) that gives you full control over the Form rendering between the form items. Alternatively, consider a [`<TelerikValidationSummary />`](slug:validation-tools-summary).
52+
* Customize the placement of the validation messages in the Form, so that they are outside the Form item containers. In this case, consider a [`<FormItemsTemplate>`](slug:form-formitems-formitemstemplate) that gives you full control over the Form rendering between the form items. Alternatively, consider a [Telerik ValidationSummary](slug:validation-tools-summary).
5353
5454
>caption Use Telerik ValidationMessage in a TelerikForm
5555
@@ -59,7 +59,7 @@ The Telerik Form [displays inline validation messages by default if validation i
5959
<TelerikForm Model="@Employee"
6060
Width="300px">
6161
<FormValidation>
62-
<DataAnnotationsValidator></DataAnnotationsValidator>
62+
<DataAnnotationsValidator />
6363
</FormValidation>
6464
<FormItems>
6565
<FormItem Field="@nameof(Person.FirstName)" LabelText="First Name">
@@ -135,15 +135,17 @@ In an existing Blazor `EditForm`, replace the `<ValidationMessage>` tags with `<
135135

136136
## Template
137137

138-
The `TelerikValidationMessage` allows you to control its rendering via a nested `<Template>` tag. The `context` represents an `IEnumerable<string>` collection of all messages for this model property.
138+
The Telerik ValidationMessage allows you to customize its rendering with a nested `<Template>` tag. The template `context` is an `IEnumerable<string>` collection of all messages for the validated model property.
139+
140+
>caption Using ValidationMessage Template
139141
140142
````RAZOR
141143
@using System.ComponentModel.DataAnnotations
142144
143145
<TelerikForm Model="@Employee"
144146
Width="300px">
145147
<FormValidation>
146-
<DataAnnotationsValidator></DataAnnotationsValidator>
148+
<DataAnnotationsValidator />
147149
</FormValidation>
148150
<FormItems>
149151
<FormItem Field="@nameof(Person.FirstName)" LabelText="First Name">
@@ -213,7 +215,6 @@ Use the `Class` parameter of the Validation Message to add a custom CSS class to
213215
## See Also
214216

215217
* [Live Demo: Validation](https://demos.telerik.com/blazor-ui/validation/overview)
216-
* [TelerikValidationSummary](slug:validation-tools-summary)
217-
* [TelerikValidationTooltip](slug:validation-tools-tooltip)
218-
* [Form Component](slug:form-overview)
219218
* [Validate Inputs in Child Components](slug:inputs-kb-validate-child-component)
219+
* [Telerik ValidationSummary](slug:validation-tools-summary)
220+
* [Telerik ValidationTooltip](slug:validation-tools-tooltip)

components/validation/overview.md

Lines changed: 6 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -10,122 +10,30 @@ position: 0
1010

1111
# Blazor Validation Tools Overview
1212

13-
Telerik UI for Blazor provides different ways to show and customize validation messages. The validation tools can be used together with the [Telerik Form](slug:form-overview) or with any form that provides an [`EditContext`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.editcontext) like the [standard .NET `EditForm`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.editform).
13+
Telerik UI for Blazor provides different ways to show and customize validation messages. The validation tools can be used together with the [Telerik Form](slug:form-overview) or with any form that provides an [`EditContext`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.editcontext) like the [standard Blazor `EditForm`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.editform).
1414

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

1717
## Validation Tools
1818

19-
Telerik provides the following validation tools to help you style your form validation:
19+
Telerik UI for Blazor provides the following validation tools to help you style your form validation:
2020

2121
* [Validation Summary](slug:validation-tools-summary)
2222
* [Validation Message](slug:validation-tools-message)
2323
* [Validation Tooltip](slug:validation-tools-tooltip)
2424

25-
These components add customization options on top of the standard validation tools the frameworks provides - `ValidationSummary` and `ValidationMessage`
25+
These components add default styling and customization options on top of the standard Blazor validation tools `ValidationSummary` and `ValidationMessage`.
2626

27-
## Integration with the TelerikForm
28-
29-
You can seamlessly integrate the validation tools with the [Form Component](slug:form-overview). To avoid duplication of validation messages, set the [ValidationMessageType](slug:form-overview#form-parameters) parameter of the form to `FormValidationMessageType.None`. You can also use the validation components in [templates with custom editors](slug:form-formitems-template) that you can define with your own code.
30-
31-
````RAZOR
32-
@* Disable the default validation messages from the Telerik Form and use the validation tools instead *@
33-
34-
@using System.ComponentModel.DataAnnotations
35-
36-
<TelerikForm Model="@person" ValidationMessageType="@FormValidationMessageType.None">
37-
<FormValidation>
38-
<DataAnnotationsValidator />
39-
<TelerikValidationSummary />
40-
</FormValidation>
41-
42-
<FormItems>
43-
<FormItem LabelText="Name" Field="@nameof(Person.Name)" Hint="This editor uses TelerikValidationTooltip" Id="NameFieldVsalidationTooltip" />
44-
<TelerikValidationTooltip For="@( () => person.Name)" TargetSelector="#NameFieldVsalidationTooltip" />
45-
46-
<FormItem LabelText="Age" Field="@nameof(Person.Age)" Hint="This editor uses TelerikValidationMessage" />
47-
<TelerikValidationMessage For="@( () => person.Age)" />
48-
49-
<FormItem LabelText="Married" Field="@nameof(Person.IsMarried)" Hint="This editor uses TelerikValidationTooltip" Id="IsMarriedFieldValidationTooltip" />
50-
<TelerikValidationTooltip For="@( () => person.IsMarried)" TargetSelector="#IsMarriedFieldValidationTooltip" />
51-
</FormItems>
52-
</TelerikForm>
53-
54-
@code {
55-
Person person = new Person();
56-
57-
public class Person
58-
{
59-
[Required]
60-
public string Name { get; set; }
61-
62-
[Required]
63-
[Range(10,150, ErrorMessage ="The age should be between 10 and 150")]
64-
public int? Age { get; set; }
65-
66-
[Required]
67-
public bool IsMarried { get; set; }
68-
}
69-
}
70-
````
71-
72-
## Integration with the Microsoft EditForm
73-
74-
````RAZOR
75-
@using System.ComponentModel.DataAnnotations
76-
77-
<EditForm Model="@person">
78-
<DataAnnotationsValidator />
79-
80-
<TelerikValidationSummary />
81-
82-
<p>
83-
<label for="NameFieldId">Name</label>
84-
<TelerikTextBox @bind-Value="@person.Name" Id="NameFieldId"></TelerikTextBox>
85-
<TelerikValidationTooltip For="@( () => person.Name)" TargetSelector="#NameFieldId" />
86-
</p>
87-
88-
<p>
89-
<label for="AgeFieldId">Age</label>
90-
<TelerikNumericTextBox @bind-Value="@person.Age" Id="AgeFieldId"></TelerikNumericTextBox>
91-
<TelerikValidationMessage For="@( () => person.Age)" />
92-
</p>
93-
94-
<p>
95-
<label for="IsMarriedFieldId">Is Married</label>
96-
<TelerikCheckBox @bind-Value="@person.IsMarried" Id="IsMarriedFieldId"></TelerikCheckBox>
97-
<TelerikValidationTooltip For="@( () => person.IsMarried)" TargetSelector="#IsMarriedFieldId" />
98-
</p>
99-
100-
<TelerikButton ButtonType="ButtonType.Submit">Submit</TelerikButton>
101-
</EditForm>
102-
103-
@code {
104-
Person person = new Person();
105-
106-
public class Person
107-
{
108-
[Required]
109-
public string Name { get; set; }
110-
111-
[Required]
112-
[Range(10, 150, ErrorMessage = "The age should be between 10 and 150")]
113-
public int? Age { get; set; }
114-
115-
[Required]
116-
public bool IsMarried { get; set; }
117-
}
118-
}
119-
````
27+
The validation components must receive an `EditContext` instance as a cascading parameter, so they can reside in a [Telerik Form](slug:form-overview) or a standard Blazor `EditForm`.
12028

12129
@[template](/_contentTemplates/common/form-validation.md#note-editcontext-formitem-template)
12230

12331
@[template](/_contentTemplates/common/form-validation.md#note-telerik-role-in-validation)
12432

12533
# Next Steps
12634

127-
* Explore [TelerikValidationSummary](slug:validation-tools-summary)
128-
* Use [TelerikValidationMessage](slug:validation-tools-message)
35+
* Use [TelerikValidationSummary](slug:validation-tools-summary)
36+
* Explore [TelerikValidationMessage](slug:validation-tools-message)
12937
* Try [TelerikValidationTooltip](slug:validation-tools-tooltip)
13038

13139
## See Also

0 commit comments

Comments
 (0)