Ejemplo n.º 1
0
        /// <summary>
        /// Mark property as required, creating a ValidationResult if this property has no value.
        /// Additional rules will only be evaluated if this rule is valid.
        /// </summary>
        /// <returns><see cref="WithRuleBuilder&lt;T, TProperty&gt;"/></returns>
        public WithRuleBuilder <T, TProperty> Required()
        {
            _propertyValidator.ConditionalAndRule(new Required <T, TProperty>());

            //_propertyValidator.PropertyValueRequired = true;
            return(new WithRuleBuilder <T, TProperty>(_propertyValidator));
        }
Ejemplo n.º 2
0
        private ActionJoinBuilder <T, TProperty> AddRuleAndReturnActionJoin(RuleValidator specRule)
        {
            if (OrNextRule)
            {
                if (NextRuleIsConditional)
                {
                    _propertyValidator.ConditionalOrRule(specRule);
                }
                else
                {
                    _propertyValidator.OrRule(specRule);
                }
            }
            else
            {
                if (NextRuleIsConditional)
                {
                    _propertyValidator.ConditionalAndRule(specRule);
                }
                else
                {
                    _propertyValidator.AndRule(specRule);
                }
            }

            return(new ActionJoinBuilder <T, TProperty>(_propertyValidator));
        }