本文整理汇总了C#中IValidator.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# IValidator.Validate方法的具体用法?C# IValidator.Validate怎么用?C# IValidator.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValidator
的用法示例。
在下文中一共展示了IValidator.Validate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateFormat
private static void ValidateFormat(List<char> delimiters, string numbers, IValidator validator)
{
if (!validator.Validate(numbers, delimiters))
{
throw new CalculatorFormatException(validator.LastErrorMessage);
}
}
示例2: ValidationTemplate
public ValidationTemplate(INotifyPropertyChanged target)
{
this.target = target;
validator = GetValidator(target.GetType());
validationResult = validator.Validate(target);
target.PropertyChanged += Validate;
}
示例3: Validate
public static void Validate(IValidator validator, object entity)
{
var result = validator.Validate(entity);
if (result.Errors.Count > 0)
{
throw new ValidationException(result.Errors);
}
}
示例4: IsValid
/// <summary>
/// Check to see if the current validation chain is valid.
/// </summary>
/// <returns>true if valid, otherwise false</returns>
public bool IsValid(ImportData readBundle, IValidator validator)
{
var valid = true;
foreach (Row row in readBundle.rows) {
validator.Validate(row);
if (!row.valid) {
valid = false;
}
}
return valid;
}
示例5: ModelBase
public ModelBase()
{
validator = ValidationFactory.GetValidator(GetType());
validationResult = validator.Validate(this);
}
示例6: PerformValidation
protected virtual void PerformValidation(object instance, IValidator validator, ModelBindingContext context)
{
string modelName = WasFallbackPerformed(context) ? string.Empty : context.ModelName;
var result = validator.Validate(instance);
result.AddToModelState(context.ModelState, modelName);
}
示例7: ValidateAndCollect
/// <summary>
/// Validates the rule and returns a boolMessage.
/// </summary>
/// <param name="rule"></param>
/// <returns></returns>
public static bool ValidateAndCollect(IValidator validator, IValidationResults results)
{
IValidationResults validationResults = validator.Validate(results);
return validationResults.IsValid;
}
示例8: Validate
/// <summary>
/// Validates the rule and returns a boolMessage.
/// </summary>
/// <param name="rule"></param>
/// <returns></returns>
public static BoolMessage Validate(IValidator validator)
{
IValidationResults results = validator.Validate() as IValidationResults;
// Empty message if Successful.
if (results.IsValid) return new BoolMessage(true, string.Empty);
// Error
string multiLineError = results.Message();
return new BoolMessage(false, multiLineError);
}
示例9: ValidatePart
void ValidatePart(JudoEntry entry, IValidator validator, CardPart cardPart)
{
var validationResponse = validator.Validate(entry.Text, _currentDiscoveredNetwork, _acceptedCardNetworks);
ChangeValidParts(cardPart, validationResponse.IsValid);
entry.Error = !validationResponse.IsValid && validationResponse.ShouldDisplayErrorMessage ? validationResponse.ErrorMessage : null;
}
示例10: Validate
public static void Validate(IValidator validator, object entityToValidate)
{
var result = validator.Validate(entityToValidate);
throw new ValidationException(result.Errors);
}
示例11: RunValidation
public List<Error> RunValidation(IValidator validator, Resource resource)
{
return validator.Validate(resource);
}