- Joined
- Jul 16, 2004
- Messages
- 270
Hi all,
I have this:
and in the ViewModel, i have this:
and in appsettings.json, i have this:
how can i read values from appsettings and set the '3, 10, 3, true, true, true, true' ?
I have this:
Code:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public class PasswordPolicyAttribute : ValidationAttribute
{
private readonly int _minimumCharacters;
private readonly int _maximumCharacters;
private readonly int _maximumConsecutiveCharacters;
private readonly bool _requiredUppercase;
private readonly bool _requiredLowercase;
private readonly bool _requiredNumericCharacters;
private readonly bool _requiredSpecialCharacters;
public PasswordPolicyAttribute(int minimumCharacters = 0,
int maximumCharacters = 0,
int maximumConsecutiveCharacters = 0,
bool requiredUppercase = false,
bool requiredLowercase = false,
bool requiredNumericCharacters = false,
bool requiredSpecialCharacters = false)
{
_minimumCharacters = minimumCharacters;
_maximumCharacters = maximumCharacters;
_maximumConsecutiveCharacters = maximumConsecutiveCharacters;
_requiredUppercase = requiredUppercase;
_requiredLowercase = requiredLowercase;
_requiredNumericCharacters = requiredNumericCharacters;
_requiredSpecialCharacters = requiredSpecialCharacters;
}
and in the ViewModel, i have this:
Code:
[PasswordPolicy(3, 10, 3, true, true, true, true)]
public string password_new { get; set; }
and in appsettings.json, i have this:
Code:
"PasswordPolicy": {
"MinimumCharacters": 2,
"MaximumCharacters": 2,
"MaximumConsecutiveCharacters": 2,
"RequiredUppercase": true,
"RequiredLowercase": true,
"RequiredNumericCharacter": true,
"RequiredSpecialCharacter": true,
how can i read values from appsettings and set the '3, 10, 3, true, true, true, true' ?