public ValidationRegistrarWithMessage(ValueValidationRegistrar registrar, IValidationRegistrar rootRegistrar, Predicate <object> predicate)
 {
     _registrar     = registrar;
     _rootRegistrar = rootRegistrar ?? throw new ArgumentNullException(nameof(rootRegistrar));
     _func          = null;
     _predicate     = predicate ?? throw new ArgumentNullException(nameof(predicate));
 }
 public ValidationRegistrarWithMessage(ValueValidationRegistrar registrar, IValidationRegistrar rootRegistrar, Func <object, bool> func)
 {
     _registrar     = registrar;
     _rootRegistrar = rootRegistrar ?? throw new ArgumentNullException(nameof(rootRegistrar));
     _func          = func ?? throw new ArgumentNullException(nameof(func));
     _predicate     = null;
 }
 public FluentValidationRegistrar(Type type, string name, IValidationRegistrar parentRegistrar)
 {
     _name                     = name;
     SourceType                = type;
     _parentRegistrar          = parentRegistrar ?? throw new ArgumentNullException(nameof(parentRegistrar));
     _verifiableObjectContract = VerifiableObjectContractManager.Resolve(type);
     Rules                     = new List <CorrectValueRule>();
 }
        /// <summary>
        /// Register for Sink Validator for FluentValidation
        /// </summary>
        /// <param name="registrar"></param>
        /// <param name="typeOfValidator"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IValidationRegistrar ForFluentValidator(this IValidationRegistrar registrar, Type typeOfValidator)
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.ForCustomValidator(FluentValidator.By(typeOfValidator)));
        }
        /// <summary>
        /// Add DataAnnotation support <br />
        /// 添加对数据注解的支持
        /// </summary>
        /// <param name="registrar"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IValidationRegistrar ForDataAnnotationSupport(this IValidationRegistrar registrar)
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.ForCustomValidator <DataAnnotationValidator>());
        }
        /// <summary>
        /// Register for Sink Validator for FluentValidation
        /// </summary>
        /// <param name="registrar"></param>
        /// <typeparam name="TValidator"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IValidationRegistrar ForFluentValidator <TValidator, T>(this IValidationRegistrar registrar)
            where TValidator : class, FluentValidation.IValidator <T>, new()
        {
            if (registrar is null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.ForCustomValidator <FluentValidator <TValidator, T> >());
        }
예제 #7
0
 public ValueValidationRegistrar(
     VerifiableMemberContract verifiableMemberContract,
     List <CorrectValueRule> rules,
     VerifyRuleMode mode,
     IFluentValidationRegistrar <T> parentRegistrar,
     IValidationRegistrar rootRegistrar)
     : base(verifiableMemberContract, rules, mode, parentRegistrar, rootRegistrar)
 {
     ValueRuleBuilder = new CorrectValueRuleBuilder <T, TVal>(verifiableMemberContract, mode);
 }
예제 #8
0
 public ValueValidationRegistrar(
     VerifiableMemberContract verifiableMemberContract,
     List <CorrectValueRule> rules,
     VerifyRuleMode mode,
     IFluentValidationRegistrar parentRegistrar,
     IValidationRegistrar rootRegistrar)
 {
     _rootRegistrar            = rootRegistrar ?? throw new ArgumentNullException(nameof(rootRegistrar));
     _parentRegistrar          = parentRegistrar ?? throw new ArgumentNullException(nameof(parentRegistrar));
     _verifiableMemberContract = verifiableMemberContract ?? throw new ArgumentNullException(nameof(verifiableMemberContract));
     ValueRuleBuilder          = new CorrectValueRuleBuilder(verifiableMemberContract, mode);
     _parentRulesRef           = rules;
 }
 private ValidationHandlerBuilder()
 {
     Registrar = ValidationRegistrar.DefaultRegistrar;
 }