Created
June 20, 2012 02:00
-
-
Save schotime/2957702 to your computer and use it in GitHub Desktop.
FluentValidation Localization Adapter
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 class FluentValidationKeys : StringToken | |
{ | |
public static StringToken CREDITCARD_ERROR = new FluentValidationKeys("'{PropertyName}' is not a valid credit card number."); | |
public static StringToken EMAIL_ERROR = new FluentValidationKeys("'{PropertyName}' is not a valid email address."); | |
public static StringToken EQUAL_ERROR = new FluentValidationKeys("'{PropertyName}' should be equal to '{PropertyValue}'."); | |
public static StringToken EXACT_LENGTH_ERROR = new FluentValidationKeys("'{PropertyName}' must be {MaxLength} characters in length. You entered {TotalLength} characters."); | |
public static StringToken EXCLUSIVEBETWEEN_ERROR = new FluentValidationKeys("'{PropertyName}' must be between {From} and {To} (exclusive). You entered {Value}."); | |
public static StringToken GREATERTHAN_ERROR = new FluentValidationKeys("'{PropertyName}' must be greater than '{ComparisonValue}'."); | |
public static StringToken GREATERTHANOREQUAL_ERROR = new FluentValidationKeys("'{PropertyName}' must be greater than or equal to '{ComparisonValue}'."); | |
public static StringToken INCLUSIVEBETWEEN_ERROR = new FluentValidationKeys("'{PropertyName}' must be between {From} and {To}. You entered {Value}."); | |
public static StringToken LENGTH_ERROR = new FluentValidationKeys("'{PropertyName}' must be between {MinLength} and {MaxLength} characters. You entered {TotalLength} characters."); | |
public static StringToken LESSTHAN_ERROR = new FluentValidationKeys("'{PropertyName}' must be less than '{ComparisonValue}'."); | |
public static StringToken LESSTHANOREQUAL_ERROR = new FluentValidationKeys("'{PropertyName}' must be less than or equal to '{ComparisonValue}'."); | |
public static StringToken NOTEMPTY_ERROR = new FluentValidationKeys("'{PropertyName}' should not be empty."); | |
public static StringToken NOTNULL_ERROR = new FluentValidationKeys("'{PropertyName}' must not be empty."); | |
public static StringToken NOTEQUAL_ERROR = new FluentValidationKeys("'{PropertyName}' should not be equal to '{PropertyValue}'."); | |
public static StringToken PREDICATE_ERROR = new FluentValidationKeys("The specified condition was not met for '{PropertyName}'."); | |
public static StringToken REGEX_ERROR = new FluentValidationKeys("'{PropertyName}' is not in the correct format."); | |
protected FluentValidationKeys(string defaultValue) : base(null, defaultValue) | |
{ | |
} | |
} | |
public class FluentValidationLocalisationAdapter | |
{ | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' is not a valid credit card number.. | |
/// </summary> | |
public static StringToken CreditCardError | |
{ | |
get { return FluentValidationKeys.CREDITCARD_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' is not a valid email address.. | |
/// </summary> | |
public static StringToken email_error | |
{ | |
get { return FluentValidationKeys.EMAIL_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' should be equal to '{PropertyValue}'.. | |
/// </summary> | |
public static StringToken equal_error | |
{ | |
get { return FluentValidationKeys.EQUAL_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be {MaxLength} characters in length. You entered {TotalLength} characters.. | |
/// </summary> | |
public static StringToken exact_length_error | |
{ | |
get { return FluentValidationKeys.EXACT_LENGTH_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be between {From} and {To} (exclusive). You entered {Value}.. | |
/// </summary> | |
public static StringToken exclusivebetween_error | |
{ | |
get { return FluentValidationKeys.EXCLUSIVEBETWEEN_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be greater than '{ComparisonValue}'.. | |
/// </summary> | |
public static StringToken greaterthan_error | |
{ | |
get { return FluentValidationKeys.GREATERTHAN_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be greater than or equal to '{ComparisonValue}'.. | |
/// </summary> | |
public static StringToken greaterthanorequal_error | |
{ | |
get { return FluentValidationKeys.GREATERTHANOREQUAL_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be between {From} and {To}. You entered {Value}.. | |
/// </summary> | |
public static StringToken inclusivebetween_error | |
{ | |
get { return FluentValidationKeys.INCLUSIVEBETWEEN_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be between {MinLength} and {MaxLength} characters. You entered {TotalLength} characters.. | |
/// </summary> | |
public static StringToken length_error | |
{ | |
get { return FluentValidationKeys.LENGTH_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be less than '{ComparisonValue}'.. | |
/// </summary> | |
public static StringToken lessthan_error | |
{ | |
get { return FluentValidationKeys.LESSTHAN_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must be less than or equal to '{ComparisonValue}'.. | |
/// </summary> | |
public static StringToken lessthanorequal_error | |
{ | |
get { return FluentValidationKeys.LESSTHANOREQUAL_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' should not be empty.. | |
/// </summary> | |
public static StringToken notempty_error | |
{ | |
get { return FluentValidationKeys.NOTEMPTY_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' should not be equal to '{PropertyValue}'.. | |
/// </summary> | |
public static StringToken notequal_error | |
{ | |
get { return FluentValidationKeys.NOTEQUAL_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' must not be empty.. | |
/// </summary> | |
public static StringToken notnull_error | |
{ | |
get { return FluentValidationKeys.NOTNULL_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to The specified condition was not met for '{PropertyName}'.. | |
/// </summary> | |
public static StringToken predicate_error | |
{ | |
get { return FluentValidationKeys.PREDICATE_ERROR; } | |
} | |
/// <summary> | |
/// Looks up a localized string similar to '{PropertyName}' is not in the correct format.. | |
/// </summary> | |
public static StringToken regex_error | |
{ | |
get { return FluentValidationKeys.REGEX_ERROR; } | |
} | |
} |
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
protected void Application_Start() | |
{ | |
ValidatorOptions.ResourceProviderType = typeof(FluentValidationLocalisationAdapter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is StringToken class here ?