using System;
using System.Collections.Generic;
using System.Text;
namespace VOL.Core.ObjectActionValidator
{
///
/// 普通参数配置
///
public class GeneralOptions
{
///
/// 自定义验证
///
///
///
public GeneralOptions(ValidatorGeneral generalName, string CNName, Func customValidator)
{
this.CNName = CNName;
this.CustomValidator = customValidator;
this.Name = generalName.ToString().ToLower();
}
///
///
///
/// 普通参数的名字,与方法参数名字必须一致(不分大小写),可以直接在ValidatorGeneral上添加
public GeneralOptions(ValidatorGeneral generalName, string CNName)
{
this.Name = generalName.ToString().ToLower();
this.CNName = CNName;
this.ParamType = ParamType.String;
}
public GeneralOptions(ValidatorGeneral generalName, string CNName, ParamType type)
{
this.Name = generalName.ToString().ToLower();
this.CNName = CNName;
this.ParamType = ParamType.String;
}
public GeneralOptions(ValidatorGeneral generalName, string CNName, int? min, int? max)
{
this.Name = generalName.ToString().ToLower();
this.CNName = CNName;
this.ParamType = ParamType.String;
this.Min = min;
this.Max = max;
}
public GeneralOptions(ValidatorGeneral generalName, string CNName, ParamType type, int? min, int? max)
{
this.Name = generalName.ToString().ToLower();
this.CNName = CNName;
this.ParamType = type;
this.Min = min;
this.Max = max;
}
public Func CustomValidator;
///
/// 方法上的参数名字
///
public string Name { get; set; }
///
/// 中文名字,参数校验错误的提示文字
///
public string CNName { get; set; }
///
/// 参数类型,目前只列出了这几种,不够自己再加
///
public ParamType ParamType { get; set; }
///
/// 数字为最小值,字符串为最小长度
///
public int? Min { get; set; }
///
/// 数字为最大值,字符串为最大长度
///
public int? Max { get; set; }
}
public enum ParamType
{
Int,
//Long,
//Byte,
Bool,
String,
DateTime,
Decimal,
Guid
}
}