You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
using Validation.Core;
|
|
|
|
|
|
using Validation.Rule.Common;
|
|
|
|
|
|
using Validation.Rule.Data;
|
|
|
|
|
|
using Validation.Rule.Format;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Validation.Validator
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 校验器工厂类
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ValidatorFactory
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 使用示例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IDataValidator CreateUserValidator()
|
|
|
|
|
|
{
|
|
|
|
|
|
var validator = new SimpleDataValidator();
|
|
|
|
|
|
validator.AddRule(new NotNullValidationRule());
|
|
|
|
|
|
validator.AddRule(new EmailValidationRule("邮箱"));
|
|
|
|
|
|
validator.AddRule(new RangeValidationRule("年龄", 18, 100));
|
|
|
|
|
|
return validator;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IDataValidator CreateXyZValidator()
|
|
|
|
|
|
{
|
|
|
|
|
|
var validator = new SimpleDataValidator();
|
|
|
|
|
|
//validator.AddRule(new NotNullValidationRule());
|
|
|
|
|
|
validator.AddRule(new MCDValidationRule("x", "y", "z"));
|
|
|
|
|
|
return validator;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|