Ejemplo n.º 1
0
        public static IValidationResult ValidateModel(this IValidate validate, object model)
        {
            var validationResults           = validate.GetValidator().Validate(model);
            IList <IValidationError> errors = new List <IValidationError>();

            foreach (var error in validationResults.Errors)
            {
                errors.Add(new GenericValidationError {
                    PropertyName = error.PropertyName, ValidationError = error.ErrorMessage
                });
            }
            return(new GenericValidationResult {
                IsValid = validationResults.IsValid, Errors = errors
            });
        }
Ejemplo n.º 2
0
 public static bool IsValid(this IValidate validate, object instance)
 {
     return(validate.GetValidator().Validate(instance).IsValid);
 }