FormValidators

用於驗證資料格式,適用於如 Web Form 控制項等輸入值皆為字串之場合。

特色

  • 豐富的內建驗證器:支援必填、型別、比較、格式等多種驗證
  • 易於客製化:可輕鬆建立自訂驗證器
  • 批量驗證管理:統一管理多個驗證器和錯誤訊息
  • Fluent API:使用 ValidationProvider 提供簡潔的語法
  • 跨框架支援:支援 .NET 10、.NET Standard 2.0 和 .NET Framework 4.5

快速開始

安裝

Install-Package CloudyWing.FormValidators

基本使用

using CloudyWing.FormValidators;

BulkValidator validators = new(cfg => {
    cfg.Add("使用者名稱", userName,
        opt => opt.Required()
    );
    cfg.Add("Email", email,
        opt => opt.Required(),
        opt => opt.Email()
    );
    cfg.Add("年齡", age,
        opt => opt.Integer(18, 100)
    );
});

if (!validators.Validate()) {
    Console.WriteLine(validators.ErrorMessage);
}

查看 快速開始指南 了解更多詳情。

文檔導航

使用指南

API 參考

授權

本專案採用 MIT 授權