예제 #1
0
        protected StringValidator <TEntity> RuleFor(Expression <Func <TEntity, string> > getterExpression)
        {
            var getter       = PropertyExpressionHelper.InitializeGetter(getterExpression);
            var propertyName = PropertyExpressionHelper.GetPropertyName(getterExpression);

            var validator = new StringValidator <TEntity>(o => getter((TEntity)o), propertyName);

            _validators.Add(validator);

            return(validator);
        }
예제 #2
0
        protected DateTimeValidator RuleFor(Expression <Func <TEntity, DateTime> > getterExpression)
        {
            var getter       = PropertyExpressionHelper.InitializeGetter(getterExpression);
            var propertyName = PropertyExpressionHelper.GetPropertyName(getterExpression);

            var intValidator = new DateTimeValidator(o => getter((TEntity)o), propertyName);

            _validators.Add(intValidator);

            return(intValidator);
        }
예제 #3
0
        protected NullableNumericValidator <TEntity, TProperty> RuleFor <TProperty>(Expression <Func <TEntity, TProperty?> > getterExpression) where TProperty : struct, IComparable
        {
            var getter       = PropertyExpressionHelper.InitializeGetter(getterExpression);
            var propertyName = PropertyExpressionHelper.GetPropertyName(getterExpression);

            var intValidator = new NullableNumericValidator <TEntity, TProperty>(o => getter((TEntity)o), propertyName);

            _validators.Add(intValidator);

            return(intValidator);
        }