Finbuckle.Html5Validation 1.0.1

Prefix Reserved
dotnet add package Finbuckle.Html5Validation --version 1.0.1                
NuGet\Install-Package Finbuckle.Html5Validation -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Finbuckle.Html5Validation" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Finbuckle.Html5Validation --version 1.0.1                
#r "nuget: Finbuckle.Html5Validation, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Finbuckle.Html5Validation as a Cake Addin
#addin nuget:?package=Finbuckle.Html5Validation&version=1.0.1

// Install Finbuckle.Html5Validation as a Cake Tool
#tool nuget:?package=Finbuckle.Html5Validation&version=1.0.1                

Finbuckle.Html5Validation

  1. Introduction
  2. Installation
  3. Supported Data Annotations
  4. License

Introduction

Client form validation in ASP.NET Core sucks.

Specifically, tag helpers and HTMLHelper methods generate non-standard validation attributes and require the use of the jquery.validate and jquery.validate.unobtrusive libraries.

This library overrides this behavior to generate standard HTML5 validation attributes.

If you like this library, check out our main project Finbuckle.MultiTenant and consider becoming a sponsor.

Installation

  1. Add the Finbuckle.Html5Validation NuGet package to your project.

  2. Add the Html5Validation service to your app:

using Finbuckle.Html5Validation;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHtml5Validation();

// Rest of app code omitted.

Supported Data Annotations

The following data annotations are supported:

Attribute ASP.NET Core Finbuckle.Html5Validation
[Required] - data-val=true<br> - data-val-required="{message}" - required
[MinLength] - minlength="{min}"<br> - data-val=true<br> - data-val-minlength="{message}" <br>- data-val-maxlength-min="{min}" - minlength="{min}"
[MaxLength] - maxlength="{max}"<br> - data-val=true<br> - data-val-maxlength="{message}" <br>- data-val-maxlength-max="{max}" - maxlength="{max}"
[StringLength] - maxlength="{max}"<br> - data-val=true<br> - data-val-maxlength="{message}" <br>- data-val-maxlength-max="{max}" <br> - data-val-minlength="{message}" <br> - data-val-maxlength-min="{min}" - minlength="{min}"<br> - maxlength="{max}"
[Range] - data-val=true<br> - data-val-range="{message}"<br> - data-val-range-min="{min}" <br>- data-val-range-max="{max}" - min="{min}"<br> - max="{max}"
[RegularExpression] - data-val=true<br> - data-val-regex="{message}"<br> - data-val-regex-pattern="{regex}" - pattern="{regex}"
[DataType(DataType.{type}] - type="{type}"<br> - data-val-{type}="{message}" - type="{type}"
[EmailAddress] - type="email"<br> - data-val-email="{message}" - type="email"
[Phone] - type="tel"<br> - data-val-phone="{message}" - type="tel"
[Url] - type="url"<br> - data-val-url="{message}" - type="url"

Note that [DataType(DataType.{type})] only supports simple types such as email, phone, and url.`

Installation

  1. Add the Finbuckle.Html5Validation NuGet package to your project.

  2. In your app configuration add the Html5Validation service:

using Finbuckle.Html5Validation;

var builder = WebApplication.CreateBuilder(args);

// ... Add normal services.

// Add Finbuclke.Html5Validation.
builder.Services.AddHtml5Validation();

// ... rest of file omitted.

License

This project is licensed under the MIT License. See LICENSE file for license information.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 369 6/21/2024
1.0.0 103 6/21/2024