本文整理汇总了C#中IPropertyValidator类的典型用法代码示例。如果您正苦于以下问题:C# IPropertyValidator类的具体用法?C# IPropertyValidator怎么用?C# IPropertyValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPropertyValidator类属于命名空间,在下文中一共展示了IPropertyValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRules
/// <summary>
/// Get the <see cref="ModelValidationRule"/> instances that are mapped from the fluent validation rule.
/// </summary>
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ModelValidationRule"/> instances.</returns>
public override IEnumerable<ModelValidationRule> GetRules(PropertyRule rule, IPropertyValidator validator)
{
yield return new ModelValidationRule(
"Custom",
base.FormatMessage(rule, validator),
base.GetMemberNames(rule));
}
示例2: Create
/// <summary>
/// Creates a <see cref="IFluentAdapter"/> instance based on the provided <paramref name="propertyValidator"/>.
/// </summary>
/// <param name="propertyValidator">The <see cref="IPropertyValidator"/> for which the adapter should be created.</param>
/// <returns>An <see cref="IFluentAdapter"/> instance.</returns>
public IFluentAdapter Create(IPropertyValidator propertyValidator)
{
var adapter =
this.adapters.SingleOrDefault(x => x.CanHandle(propertyValidator));
return adapter ?? new FallbackAdapter();
}
示例3: PropertyType
public PropertyType(int key, IPropertyValidator propertyValidator, GroupTypeCollection groupsRead, GroupTypeCollection groupsWrite)
{
Key = key;
Validator = propertyValidator;
GroupsReadInternal = groupsRead;
GroupsWriteInternal = groupsWrite;
}
示例4: GetRules
/// <summary>
/// Get the <see cref="ModelValidationRule"/> instances that are mapped from the fluent validation rule.
/// </summary>
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ModelValidationRule"/> instances.</returns>
public override IEnumerable<ModelValidationRule> GetRules(PropertyRule rule, IPropertyValidator validator)
{
yield return new RegexValidationRule(
FormatMessage(rule, validator),
GetMemberNames(rule),
((IRegularExpressionValidator)validator).Expression);
}
示例5: GeneratorFrom
public Rule GeneratorFrom(string propertyName, IPropertyValidator propertyValidator)
{
return new Required
{
Message = propertyValidator.GetErrorMessageFor(propertyName)
};
}
示例6: DataAnnotationsValidatorFixture
public DataAnnotationsValidatorFixture()
{
this.propertyValidator1 =
A.Fake<IPropertyValidator>();
this.propertyValidator2 =
A.Fake<IPropertyValidator>();
this.validatableObjectAdapter =
A.Fake<IValidatableObjectAdapter>();
this.validatorFactory =
A.Fake<IPropertyValidatorFactory>();
A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest)))
.Returns(new[] { this.propertyValidator1, this.propertyValidator2 });
this.validator =
new DataAnnotationsValidator(typeof(ModelUnderTest), this.validatorFactory, this.validatableObjectAdapter);
var adapterFactory = new DefaultPropertyValidatorFactory(new IDataAnnotationsValidatorAdapter[]
{
new RangeValidatorAdapter(),
new RegexValidatorAdapter(),
new RequiredValidatorAdapter(),
new StringLengthValidatorAdapter(),
new OopsAdapter()
});
var adapter = A.Fake<IValidatableObjectAdapter>();
this.factory = new DataAnnotationsValidatorFactory(adapterFactory, adapter);
}
示例7: GeneratorFrom
public Rule GeneratorFrom(IPropertyValidator propertyValidator)
{
return new Required
{
Message = propertyValidator.ErrorMessageSource.GetString()
};
}
示例8: GeneratorFrom
public Rule GeneratorFrom(IPropertyValidator propertyValidator)
{
return new LessThanOrEqual
{
Value = ((LessThanOrEqualValidator)propertyValidator).ValueToCompare,
Message = propertyValidator.ErrorMessageSource.GetString()
};
}
示例9: GeneratorFrom
public Rule GeneratorFrom(IPropertyValidator propertyValidator)
{
var emailRule = new Email
{
Message = propertyValidator.ErrorMessageSource.GetString()
};
return emailRule;
}
示例10: GetRules
/// <summary>
/// Get the <see cref="ModelValidationRule"/> instances that are mapped from the fluent validation rule.
/// </summary>
/// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ModelValidationRule"/> instances.</returns>
public override IEnumerable<ModelValidationRule> GetRules(PropertyRule rule, IPropertyValidator validator)
{
yield return new ComparisonValidationRule(
base.FormatMessage(rule, validator),
base.GetMemberNames(rule),
ComparisonOperator.LessThan,
((LessThanValidator)validator).ValueToCompare);
}
示例11: GeneratorFrom
public Rule GeneratorFrom(string propertyName, IPropertyValidator propertyValidator)
{
return new GreaterThanOrEqual
{
Value = ((GreaterThanOrEqualValidator)propertyValidator).ValueToCompare,
Message = propertyValidator.GetErrorMessageFor(propertyName)
};
}
示例12: RequiredFluentValidationPropertyValidator
public RequiredFluentValidationPropertyValidator(ModelMetadata metadata, ControllerContext controllerContext, PropertyRule rule, IPropertyValidator validator)
: base(metadata, controllerContext, rule, validator)
{
bool isNonNullableValueType = !TypeAllowsNullValue(metadata.ModelType);
bool nullWasSpecified = metadata.Model == null;
ShouldValidate = isNonNullableValueType && nullWasSpecified;
}
开发者ID:henriksoerensen,项目名称:FluentValidation,代码行数:8,代码来源:RequiredFluentValidationPropertyValidator.cs
示例13: GeneratorFrom
public Rule GeneratorFrom(string propertyName, IPropertyValidator propertyValidator)
{
var emailRule = new Email
{
Message = propertyValidator.GetErrorMessageFor(propertyName)
};
return emailRule;
}
示例14: GeneratorFrom
public Rule GeneratorFrom(string propertyName, IPropertyValidator propertyValidator)
{
return new LessThan
{
Value = ((LessThanValidator)propertyValidator).ValueToCompare,
Message = propertyValidator.GetErrorMessageFor(propertyName)
};
}
示例15: GeneratorFrom
public Rule GeneratorFrom(IPropertyValidator propertyValidator)
{
return new GreaterThan
{
Value = ((GreaterThanValidator)propertyValidator).ValueToCompare,
Message = propertyValidator.ErrorMessageSource.GetString()
};
}