MvcValidatorToolkit/Validators/ValidateElement.cs
/// <summary>
/// Translates and returns the validator instances to use for the validation process.
/// </summary>
Translates and returns the validator instances to use for the validation process.
Translates and returns the validator instances to use for the validation process .
public override Validator[] Translate()
		{
			List<Validator> attributes = new List<Validator>();
			foreach(string element in ElementsToValidate)
			{
				if(Required)
					attributes.Add(new ValidatePresence(element));
				if(Min > 0 && Max > 0)
					attributes.Add(new ValidateRange(element, Min, Max));
				else if(Min > 0)
					attributes.Add(new ValidateMin(element, Min));
				else if(Max > 0)
					attributes.Add(new ValidateMax(element, Max));
				if(MinLength > 0 && MaxLength > 0)
					attributes.Add(new ValidateRangeLength(element, MinLength, MaxLength));
				else if(MinLength > 0)
					attributes.Add(new ValidateMinLength(element, MinLength));
				else if(MaxLength > 0)
					attributes.Add(new ValidateMaxLength(element, MaxLength));
			}
			return attributes.ToArray();
		}
public override Validator [ ] Translate ( ) { List < Validator > attributes = new List < Validator > ( ) ; foreach ( string element in ElementsToValidate ) { if ( Required ) attributes . Add ( new ValidatePresence ( element ) ) ; if ( Min > 0 && Max > 0 ) attributes . Add ( new ValidateRange ( element , Min , Max ) ) ; else if ( Min > 0 ) attributes . Add ( new ValidateMin ( element , Min ) ) ; else if ( Max > 0 ) attributes . Add ( new ValidateMax ( element , Max ) ) ; if ( MinLength > 0 && MaxLength > 0 ) attributes . Add ( new ValidateRangeLength ( element , MinLength , MaxLength ) ) ; else if ( MinLength > 0 ) attributes . Add ( new ValidateMinLength ( element , MinLength ) ) ; else if ( MaxLength > 0 ) attributes . Add ( new ValidateMaxLength ( element , MaxLength ) ) ; } return attributes . ToArray ( ) ; }
Translates and returns the validator instances to use for the validation process.
Translates and returns the validator instances to use for the validation process .