Represents a validation configuration that can be rendered to the client
Esempio n. 1
0
        public void Can_Add_Rules_To_ValidationInfo()
        {
            ValidationInfo.Formatter = new TestRulesFormatter();

            var validationInfo = new ValidationInfo(RuleSet.Empty);
            Assert.Equal("", validationInfo.ToString());

            validationInfo.AddRule("prop1", new RequiredRule());
            Assert.Equal("prop1=Required,", validationInfo.ToString());

            validationInfo.AddRule("prop2", new StringLengthRule(2, 3));
            Assert.Equal("prop1=Required,prop2=StringLength,", validationInfo.ToString());
        }
        public string GetValidationData(IClientSideValidationArgs args)
        {
            xValClientSideValidationArgs xValArgs = args as xValClientSideValidationArgs;

            Type t = xValArgs.DataType;

            if (xValArgs.UseIoCToResolveType)
            {
                object o = ObjectFactory.TryGet<object>(t);
                if (null != o)
                {
                    t = o.GetType();
                }
            }

            ValidationInfo vi = new ValidationInfo(ActiveRuleProviders.GetRulesForType(t), xValArgs.ElementPrefix);
            return vi.ToString();
        }