예제 #1
0
        private static void fillFields(ValidationOptions options, IValidationNode node, IServiceLocator services, Accessor accessor, Type type)
        {
            var mode  = node.DetermineMode(services, accessor);
            var field = new FieldOptions
            {
                field = accessor.Name,
                mode  = mode.Mode
            };

            var graph       = services.GetInstance <ValidationGraph>();
            var rules       = graph.FieldRulesFor(type, accessor);
            var ruleOptions = new List <FieldRuleOptions>();

            rules.Each(rule =>
            {
                var ruleMode = rule.Mode ?? mode;
                ruleOptions.Add(new FieldRuleOptions
                {
                    rule = RuleAliases.AliasFor(rule),
                    mode = ruleMode.Mode
                });
            });

            field.rules = ruleOptions.ToArray();

            options._fields.Add(field);
        }
예제 #2
0
        public void Add(IFieldValidationRule rule)
        {
            var key = RuleAliases.AliasFor(rule);

            _messages.Fill(key, rule.Token.ToString());
        }