技术人员...
我有以下员工课程。
public class Employee
{
public string Name { get; set; }
public double Salary { get; set; }
}
我只想将双重属性 Salary 的验证设置为仅接受数字。
我试过像下面这样。
<configuration>
<configSections>
<section name="validation" type="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationSettings, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<validation>
<type name="namespace.Model.Common.Masters.Employee" defaultRuleset="SaveRuleset"
assemblyName="namespace.Model.Common.Masters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<ruleset name="SaveRuleset">
<properties>
<property name="Salary">
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.OrCompositeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
messageTemplate="Salary accept numbers only." name="Or Composite Validator">
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
negated="true" name="Not Null Validator" />
<validator type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RegexValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
pattern="^[0-9]" name="Regular Expression Validator" />
</validator>
</property>
</properties>
</ruleset>
</type>
</validation>
</configuration>
我必须使用正则表达式吗?还要注意我无法设置 RangeValidator。
有人可以帮我吗?
提前致谢,
问候,斯拉万。