protected override void Validate(DomainObject domainObject, DomainProperty property, string propertyValue, ValidationResult result) { if (string.IsNullOrEmpty(propertyValue)) { return; //是否能为空的验证由别的验证器处理 } if (!IsMatch(propertyValue)) { result.AddError(property.Name, "MobileNumber", string.Format(Extensions.Strings.IncorrectMobileNumberFormat, property.Name)); } }
protected override void Validate(DomainObject domainObject, DomainProperty property, byte propertyValue, ValidationResult result) { if (propertyValue < this.Min) { result.AddError(property.Name, ErrorCode, string.Format(Strings.ValueLessThan, property.Name, this.Min)); } else if (propertyValue > this.Max) { result.AddError(property.Name, ErrorCode, string.Format(Strings.ValueMoreThan, property.Name, this.Max)); } }