コード例 #1
0
        private IEnumerable <IFieldValidationRule> rulesFor(Expression <Func <ClassValidationRulesTarget, object> > expression)
        {
            var registry = new FieldRulesRegistry(new IFieldValidationSource[0], new TypeDescriptorCache());
            var graph    = ValidationGraph.For(registry);

            graph.Import(theRules);

            return(registry.RulesFor(typeof(ClassValidationRulesTarget)).RulesFor(expression.ToAccessor()));
        }
コード例 #2
0
        protected override void beforeEach()
        {
            theModel         = new SimpleModel();
            theRecordingRule = new RecordingValidationRule();

            var theSource = ConfiguredValidationSource.For(theModel.GetType(), theRecordingRule);

            theGraph = ValidationGraph.For(theSource);

            Services.Inject <ITypeResolver>(new TypeResolver());
            Services.Inject(theGraph);

            ClassUnderTest.Validate(theModel);

            theContext = theRecordingRule.Context;
        }
コード例 #3
0
        public void SetUp()
        {
            token1 = StringToken.FromKeyString("TestKeys:Key1", "Token 1");
            token2 = StringToken.FromKeyString("TestKeys:Key2", "Token 2");

            rule1       = FieldEqualityRule.For <LoFiTarget>(x => x.Value1, x => x.Value2);
            rule1.Token = token1;

            rule2       = FieldEqualityRule.For <LoFiTarget>(x => x.Value1, x => x.Value2);
            rule2.Token = token2;

            var source = new ConfiguredValidationSource(new IValidationRule[] { rule1, rule2 });

            theValidationGraph = ValidationGraph.For(source);

            theGraph = BehaviorGraph.BuildFrom(x =>
            {
                x.Actions.IncludeType <FormValidationModeEndpoint>();
                x.Import <FubuMvcValidation>();
            });
        }
コード例 #4
0
        private IEnumerable <IValidationRule> classRules()
        {
            var graph = ValidationGraph.For(theRules);

            return(graph.Sources.SelectMany(source => source.RulesFor(typeof(ClassValidationRulesTarget))));
        }