diff --git a/docs/validation.md b/docs/validation.md index 3aa0739..8b8eacc 100644 --- a/docs/validation.md +++ b/docs/validation.md @@ -5,6 +5,8 @@ QuickForm has two types of validation - `DataAnnotationsValidator` - [`Blazored.FluentValidationValidator`](https://github.com/Blazored/FluentValidation) +Both of which can be disabled with setting `EnableDataAnnotationsValidation` and `EnableFluentValidation` parameters to false. + ## DataAnnotationAttributes ```csharp diff --git a/src/QuickForm/Components/QuickForm.razor b/src/QuickForm/Components/QuickForm.razor index dd55a2e..c9f95fe 100644 --- a/src/QuickForm/Components/QuickForm.razor +++ b/src/QuickForm/Components/QuickForm.razor @@ -6,8 +6,15 @@ - - + @if (EnableDataAnnotationsValidation) + { + + } + + @if (EnableFluentValidation) + { + + } @foreach (var field in Fields) { diff --git a/src/QuickForm/Components/QuickForm.razor.cs b/src/QuickForm/Components/QuickForm.razor.cs index 315f731..ae29886 100644 --- a/src/QuickForm/Components/QuickForm.razor.cs +++ b/src/QuickForm/Components/QuickForm.razor.cs @@ -29,11 +29,23 @@ public partial class QuickForm : ComponentBase, IDisposable [Parameter] public string InvalidClass { get; set; } = "invalid"; + /// + /// Gets or sets the flag to enable or disable data annotations validation. + /// + [Parameter] + public bool EnableDataAnnotationsValidation { get; set; } = true; + + /// + /// Gets or sets the flag to enable or disable fluent validation. + /// + [Parameter] + public bool EnableFluentValidation { get; set; } = true; + /// /// Gets or sets the template for the fields in this form. /// [Parameter] - public virtual RenderFragment ChildContent { get; set; } = _ => builder => + public RenderFragment ChildContent { get; set; } = _ => builder => { builder.OpenElement(0, "div"); builder.AddContent(1, "You must provide ChildContent unless you are using a custom form template."); @@ -47,7 +59,7 @@ public partial class QuickForm : ComponentBase, IDisposable /// Make sure to give this button `type="submit"` to make it work. /// [Parameter] - public virtual RenderFragment? SubmitButtonTemplate { get; set; } + public RenderFragment? SubmitButtonTemplate { get; set; } /// /// Gets or sets the callback to be invoked when the model changes. diff --git a/src/QuickForm/QuickForm.csproj b/src/QuickForm/QuickForm.csproj index 6076ba9..64a285a 100644 --- a/src/QuickForm/QuickForm.csproj +++ b/src/QuickForm/QuickForm.csproj @@ -14,7 +14,7 @@ aspnetcore, components, blazor, forms icon.png MIT - 2.0.3 + 2.0.4