private void GivingRulesFor(string propertyName, out ITagableRule minAttribute, out ITagableRule maxAttribute) { IClassValidator cv = ve.GetClassValidator(typeof(EntityXml)); IEnumerable <Attribute> ma = cv.GetMemberConstraints(propertyName); minAttribute = (ITagableRule)ma.First(a => a.TypeId == minTypeId); maxAttribute = (ITagableRule)ma.First(a => a.TypeId == maxTypeId); }
public void GetMemberConstraints() { IClassValidator cv = GetClassValidator(typeof(Address)); IEnumerable <Attribute> ma = cv.GetMemberConstraints("country"); Assert.That(ma.Count(), Is.EqualTo(2)); Assert.That(ma.Count(x => x.TypeId == (new NotNullAttribute()).TypeId), Is.EqualTo(1)); Assert.That(ma.Count(x => x.TypeId == (new LengthAttribute()).TypeId), Is.EqualTo(1)); }
public void GetMemberConstraintsLoquacious() { var configure = new FluentConfiguration(); configure.Register( Assembly.GetExecutingAssembly().ValidationDefinitions().Where(x => x.Equals(typeof(AddressDef)))) .SetDefaultValidatorMode(ValidatorMode.UseExternal); var ve = new ValidatorEngine(); ve.Configure(configure); IClassValidator cv = ve.GetValidator <Address>(); IEnumerable <Attribute> ma = cv.GetMemberConstraints("Country"); Assert.That(ma.Count(), Is.EqualTo(2)); Assert.That(ma.Count(x => x.TypeId == (new NotNullAttribute()).TypeId), Is.EqualTo(1)); Assert.That(ma.Count(x => x.TypeId == (new LengthAttribute()).TypeId), Is.EqualTo(1)); }