/// <summary> /// Adds the validation service to the specified service collection. /// </summary> /// <param name="services">The services to add the service to.</param> /// <param name="requirements">The optional requirements to for the validator.</param> public static void AddValidationService(this IServiceCollection services, PasswordRequirements requirements = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } services.AddScoped <IValidatorService, ValidatorService>(x => new ValidatorService(requirements ?? PasswordRequirements.Default)); }
/// <summary> /// Initializes a new instance of the <see cref="ValidatorService"/> class, with the specified password validation rules configuration. /// </summary> /// <param name="requirements">The validation rules to use when validating a password.</param> public ValidatorService(PasswordRequirements requirements) { this.requirements = requirements ?? throw new ArgumentNullException(nameof(requirements)); }