1
我有一个类:FluentValidation与WithMessage一起使用枚举?
public class CustomerType
{
public int Number { get; set; }
}
而且枚举验证错误:
public enum CustomerTypeError
{
None,
NotNumber,
}
然后,我有这个校验目前看起来是这样的:
public class CustomerTypeValidator : AbstractValidator<CustomerType>
{
public CustomerTypeValidator()
{
RuleFor(x => x.Number).GreaterThanOrEqualTo("").WithMessage("Number must be greater than 0.");
}
}
我不我不想对消息进行硬编码,而且我也没有使用资源文件,因为这是应用程序的服务器端。我想返回一个CustomerTypeError值。
这可能吗?