C# FluentValidation是否将枚举与WithMessage一起使用?

C# FluentValidation是否将枚举与WithMessage一起使用?,c#,fluentvalidation,C#,Fluentvalidation,我有一门课: public class CustomerType { public int Number { get; set; } } 以及验证错误的枚举: public enum CustomerTypeError { None, NotNumber, } 然后我有一个validator类,它现在看起来像这样: public class CustomerTypeValidator : AbstractValidator<CustomerType> {

我有一门课:

public class CustomerType
{
    public int Number { get; set; }
}
以及验证错误的枚举:

public enum CustomerTypeError
{
    None,
    NotNumber,
}
然后我有一个validator类,它现在看起来像这样:

public class CustomerTypeValidator : AbstractValidator<CustomerType>
{
    public CustomerTypeValidator()
    {
        RuleFor(x => x.Number).GreaterThanOrEqualTo("").WithMessage("Number must be greater than 0.");
    }
}
公共类CustomerTypeValidator:AbstractValidator
{
公共CustomerTypeValidator()
{
规则(x=>x.Number).GreaterThanOrEqualTo(“”).WithMessage(“数字必须大于0”);
}
}
我不想硬编码消息,也不使用资源文件,因为这是应用程序的服务器端。我想返回CustomerTypeError值

这可能吗?

我正在使用.WithState(),然后从ValidationFailure对象中读取CUstomState。这就成功了