public static void ShouldBeLikeDefault(this IValidatorSettings @this) { @this.Should().NotBeNull(); @this.Translations.Keys.Should().HaveCount(1); @this.Translations.Keys.Should().Contain("English"); @this.Translations["English"].Should().NotBeNull(); foreach (var pair in Translation.English) { @this.Translations["English"].Keys.Should().Contain(pair.Key); @this.Translations["English"][pair.Key].Should().Be(pair.Value); } }
/// <summary> /// Creates instance of <see cref="IValidator{T}"/> that can validate objects of type <typeparamref name="T"/> against the provided specification. /// </summary> /// <param name="specification">Specification used to validate models.</param> /// <param name="settings">Settings used to validate models.</param> /// <typeparam name="T">Type of the models that this instance of <see cref="IValidator{T}"/> can validate.</typeparam> /// <returns>Instance of <see cref="IValidator{T}"/>, fully initialized and ready to work.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="settings"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="settings"/> is not an instance of <see cref="ValidatorSettings"/>.</exception> public IValidator <T> Create <T>(Specification <T> specification, IValidatorSettings settings) { var modelScheme = ModelSchemeFactory.Create(specification); if (settings is null) { throw new ArgumentNullException(nameof(settings)); } if (!(settings is ValidatorSettings validatorSettings)) { throw new ArgumentException($"Custom {nameof(IValidatorSettings)} implementations are not supported.", nameof(settings)); } validatorSettings.IsLocked = true; return(new Validator <T>(modelScheme, settings)); }
public ValidatorTests() { _settings = new ValidatorSettings(); _validator = new Validator(_settings); }
public Validator(IValidatorSettings settings) { _settings = settings; }