/// <summary> /// When implemented in a derived class, returns metadata for client validation. /// </summary> /// <returns> /// The metadata for client validation. /// </returns> public override IEnumerable <ModelClientValidationRule> GetClientValidationRules() { ValidatorProperties validatorProperties = ValidationRule.Validator.GetValidatorProperties(); string message = ValidationRule.GetValidationMessage(Metadata.Model); yield return(new ModelClientValidationRangeRule(message, null, validatorProperties.GetPropertyValue(Constants.ValidationMessageParameterNames.VALUE_TO_COMPARE))); }
/// <summary> /// When implemented in a derived class, returns metadata for client validation. /// </summary> /// <returns> /// The metadata for client validation. /// </returns> public override IEnumerable <ModelClientValidationRule> GetClientValidationRules() { string message = ValidationRule.GetValidationMessage(Metadata.Model); yield return(new ModelClientValidationRule { ValidationType = "creditcard", ErrorMessage = message }); }
/// <summary> /// When implemented in a derived class, returns metadata for client validation. /// </summary> /// <returns> /// The metadata for client validation. /// </returns> public override IEnumerable <ModelClientValidationRule> GetClientValidationRules() { ValidatorProperties validatorProperties = ValidationRule.Validator.GetValidatorProperties(); MemberInfo memberToCompareMemberInfo = validatorProperties.GetPropertyValue <MemberInfo>(Constants.ValidationMessageParameterNames.MEMBER_TO_COMPARE_MEMBER_INFO); PropertyInfo propertyInfoToCompare = memberToCompareMemberInfo as PropertyInfo; if (propertyInfoToCompare != null) { string message = ValidationRule.GetValidationMessage(Metadata.Model); Type ownerType = validatorProperties.GetPropertyValue <Type>(Constants.ValidationMessageParameterNames.OWNER_TYPE); string validationModelPropertyName = propertyInfoToCompare.Name; string propertyName = GetTransformedPropertyName(validationModelPropertyName, ownerType) ?? validationModelPropertyName; string propertyForClientValidation = CompareAttribute.FormatPropertyForClientValidation(propertyName); yield return(new ModelClientValidationEqualToRule(message, propertyForClientValidation)); } }
/// <summary> /// When implemented in a derived class, returns metadata for client validation. /// </summary> /// <returns> /// The metadata for client validation. /// </returns> public override IEnumerable <ModelClientValidationRule> GetClientValidationRules() { string message = ValidationRule.GetValidationMessage(Metadata.Model); yield return(new ModelClientValidationRequiredRule(message)); }