public void NotXssStringTestCreatesXssValidator() { _validator.RuleFor(x => x.StringVal).NotXssString(); var rule = (IValidationRule <Dummy>)_validator.First(); Assert.IsType <XssValidator <Dummy, string> >(rule.Components.LastOrDefault()?.Validator); rule.Member.Name.Should().Be("StringVal"); }
public void Always_use_specific_language_with_string_source() { ValidatorOptions.Global.LanguageManager.Culture = new CultureInfo("fr-FR"); var validator = new InlineValidator<Person>(); validator.RuleFor(x => x.Surname).NotNull(); var component = (RuleComponent<Person,string>)validator.First().Components.First(); var msg = component.GetErrorMessage(null, null); ValidatorOptions.Global.LanguageManager.Culture = null; msg.ShouldEqual("'{PropertyName}' ne doit pas avoir la valeur null."); }