CloudyWing.FormValidators
3.2.0
.NET 10.0
This package targets .NET 10.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.5
This package targets .NET Framework 4.5. The package is compatible with this framework or higher.
dotnet add package CloudyWing.FormValidators --version 3.2.0
NuGet\Install-Package CloudyWing.FormValidators -Version 3.2.0
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="CloudyWing.FormValidators" Version="3.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CloudyWing.FormValidators" Version="3.2.0" />
<PackageReference Include="CloudyWing.FormValidators" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CloudyWing.FormValidators --version 3.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CloudyWing.FormValidators, 3.2.0"
#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.
#:package CloudyWing.FormValidators@3.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CloudyWing.FormValidators&version=3.2.0
#tool nuget:?package=CloudyWing.FormValidators&version=3.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FormValidators
用於驗證資料格式,適用於如 Web Form 控制項等輸入值皆為字串之場合。 不過 Web Form 本身有 Validation Controls,所以除非捨棄 Validation Controls,自行定義驗證方式,否則此專案更多是用於記錄資料驗證的方式,偏向娛樂性質居多。
支援版本
- net10.0
- netstandard2.0
- net45
使用方式
using CloudyWing.FormValidators;
BulkValidator validators = new(cfg => {
cfg.Add("使用者名稱", userName,
opt => opt.Required(),
opt => opt.LengthRange(3, 20)
);
cfg.Add("Email", email,
opt => opt.Required(),
opt => opt.Email()
);
cfg.Add("年齡", age,
opt => opt.IntRange(18, 100)
);
});
if (!validators.Validate()) {
Console.WriteLine(validators.ErrorMessage);
}
功能
- 必填、長度、整數、數值、日期與欄位比較驗證。
- Email、手機、市話、身分證、統一編號、信用卡、URL、IP 位址與 GUID 格式驗證。
- 允許值清單(
In)、自訂判斷式(Custom)與非同步判斷式(CustomAsync)驗證。 BulkValidator批量驗證,可取得字串或結構化的Errors錯誤結果,並支援ValidateAsync非同步驗證。- 以
ErrorMessageProvider全域設定預設錯誤訊息,或以BeginScope在限定範圍內覆寫。
注意事項
- 整數、數值與日期預設以目前的文化特性解析,需要固定格式時請傳入
IFormatProvider或日期格式。 - 驗證器執行個體會保存最後一次驗證的結果,不是執行緒安全的型別,請不要跨執行緒共用。
ErrorMessageProvider與ValidatorDefaults是整個應用程式共用的設定,請在應用程式啟動時設定。UrlValidator為了相容舊版,預設接受任何 scheme,包含javascript:與file:。驗證使用者輸入的連結時,請傳入allowedSchemes限定為http與https,例如opt.Url(UriKind.Absolute, ["http", "https"]),詳見驗證器介紹。
Documentation
完整文件請參考:https://cloudywing.github.io/FormValidators/
或查看以下主要文章:
License
This project is MIT licensed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net10.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.