Beispiel #1
0
        private static IRecordValidator CreateValidator(string validatorType)
        {
            if (validatorType.Equals("custom", StringComparison.InvariantCultureIgnoreCase))
            {
                validatorSettings = Config.GetSection("custom").Get <ValidatorSettings>();
            }
            else
            {
                validatorSettings = Config.GetSection("default").Get <ValidatorSettings>();
            }

            var validator = new ValidatorBuilder()
                            .ValidateFirstName(validatorSettings.FirstName.Min, validatorSettings.FirstName.Max)
                            .ValidateLastName(validatorSettings.LastName.Min, validatorSettings.LastName.Max)
                            .ValidateDateOfBirth(validatorSettings.DateOfBirth.From, validatorSettings.DateOfBirth.To)
                            .ValidateGender(validatorSettings.Gender.ToCharArray())
                            .ValidateOffice(validatorSettings.Office.Min, validatorSettings.Office.Max)
                            .ValidateSalary(validatorSettings.Salary.Min, validatorSettings.Salary.Max)
                            .Create();

            return(validator);
        }
Beispiel #2
0
 /// <summary>
 /// Creates the custom.
 /// </summary>
 /// <param name="validatorBuilder">The validator builder.</param>
 /// <returns>The custom validator.</returns>
 public static IRecordValidator CreateCustom(this ValidatorBuilder validatorBuilder)
 => CreateValidator("custom");
Beispiel #3
0
 /// <summary>
 /// Creates the default.
 /// </summary>
 /// <param name="validatorBuilder">The validator builder.</param>
 /// <returns>The default validator.</returns>
 public static IRecordValidator CreateDefault(this ValidatorBuilder validatorBuilder)
 => CreateValidator("default");