-
-
Save LSTANCZYK/a0293dc0a99d4054fc2296eff324751f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class ValidatePasswordLengthAttribute : ValidationAttribute | |
{ | |
private const string _defaultErrorMessage = "'{0}' must be at least {1} characters long."; | |
private readonly int _minCharacters = Membership.Provider.MinRequiredPasswordLength; | |
public ValidatePasswordLengthAttribute() | |
: base(_defaultErrorMessage) | |
{ | |
} | |
public override string FormatErrorMessage(string name) | |
{ | |
return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString, | |
name, _minCharacters); | |
} | |
public override bool IsValid(object value) | |
{ | |
string valueAsString = value as string; | |
return (valueAsString != null && valueAsString.Length >= _minCharacters); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment