public override void Validate( string value )
{
base.Validate( value );
if ( MinLength != NoLengthRestriction && value.Length < MinLength ) {
throw new FormatException( String.Format( "Value string is too short; expected at least {0} characters.",
MinLength ) );
}
if ( MaxLength != NoLengthRestriction && value.Length > MaxLength ) {
throw new FormatException( String.Format( "Value string too long; expected at most {0} characters.",
MaxLength ) );
}
if ( RestrictedChars && Chat.ContainsInvalidChars( value ) ) {
throw new FormatException( String.Format( "Value contains restricted characters." ) );
}
if ( Regex != null && !Regex.IsMatch( value ) ) {
throw new FormatException( String.Format( "Value does not match the expected format: /{0}/.",
Regex ) );
}
}