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); }
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); }
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); }