Esempio n. 1
0
        /// <summary>
        /// This action rule is used when you need to match on multiple parameters
        /// <br/>
        /// The parameterInfos are used to match the exact controller Action,
        /// if more than one exists with the same name,
        /// or if you want to ensure the parameters explicitly by configuration
        /// <br/>
        /// see also <seealso cref="AddActionRule{T}(string,MyParameterInfo,Attribute)" />
        /// </summary>
        public ValidatorBuilder AddActionRule <T>(string actionName, IEnumerable <MyParameterInfo> parameterInfos, Attribute attributeRequired) where T : ControllerBase
        {
            var validationRuleUserDefined = new ActionRuleConfiguredByUser <T>(actionName, parameterInfos, attributeRequired);

            _validator.ValidationRulesConfiguredByUser.Add(validationRuleUserDefined);
            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// This rule type is the simplest to use.
        /// <br/>
        /// Note that if you have more than one action with the same name
        /// this rule will only be applied to the first action found
        /// in the order as found in the controller class.
        /// <br/>
        /// If you need different rules on f ex two Get methods in the same controller
        /// you should use the overloads that takes parameterInfo(s),
        ///  or just name your methods explicitly (like : GetAll and GetById)
        /// </summary>
        public ValidatorBuilder AddActionRule <T>(string actionName, Attribute attributeRequired) where T : ControllerBase
        {
            var validationRuleAction = new ActionRuleConfiguredByUser <T>(actionName, attributeRequired);

            _validator.ValidationRulesConfiguredByUser.Add(validationRuleAction);
            return(this);
        }