Class BaseValidator<T>
- Namespace
- Cratis.Applications.Validation
- Assembly
- Cratis.Applications.dll
Represents a base validator that we use for discovery.
public class BaseValidator<T> : AbstractValidator<T>, IValidator<T>, IValidator, IEnumerable<IValidationRule>, IEnumerableType Parameters
- T
- Type of object the validator is for. 
- Inheritance
- 
      
      AbstractValidator<T>BaseValidator<T>
- Implements
- 
      IValidator<T>IValidatorIEnumerable<IValidationRule>
- Derived
- Inherited Members
- 
    AbstractValidator<T>.Validate(T)AbstractValidator<T>.Validate(ValidationContext<T>)AbstractValidator<T>.CreateDescriptor()AbstractValidator<T>.WhenAsync(Func<T, ValidationContext<T>, CancellationToken, Task<bool>>, Action)AbstractValidator<T>.Include(IValidator<T>)AbstractValidator<T>.GetEnumerator()AbstractValidator<T>.PreValidate(ValidationContext<T>, ValidationResult)AbstractValidator<T>.RaiseValidationException(ValidationContext<T>, ValidationResult)AbstractValidator<T>.OnRuleAdded(IValidationRule<T>)AbstractValidator<T>.ClassLevelCascadeModeAbstractValidator<T>.RuleLevelCascadeMode
- Extension Methods
Methods
RuleFor(Expression<Func<T, ConceptAs<bool>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for bool.
public IRuleBuilderInitial<T, bool> RuleFor(Expression<Func<T, ConceptAs<bool>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<bool>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, bool>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<byte>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for byte.
public IRuleBuilderInitial<T, byte> RuleFor(Expression<Func<T, ConceptAs<byte>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<byte>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, byte>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<DateOnly>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for DateOnly.
public IRuleBuilderInitial<T, DateOnly> RuleFor(Expression<Func<T, ConceptAs<DateOnly>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<DateOnly>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, DateOnly>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<DateTimeOffset>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for DateTimeOffset.
public IRuleBuilderInitial<T, DateTimeOffset> RuleFor(Expression<Func<T, ConceptAs<DateTimeOffset>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<DateTimeOffset>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, DateTimeOffset>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<DateTime>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for DateTime.
public IRuleBuilderInitial<T, DateTime> RuleFor(Expression<Func<T, ConceptAs<DateTime>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<DateTime>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, DateTime>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<decimal>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for decimal.
public IRuleBuilderInitial<T, decimal> RuleFor(Expression<Func<T, ConceptAs<decimal>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<decimal>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, decimal>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<double>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for double.
public IRuleBuilderInitial<T, double> RuleFor(Expression<Func<T, ConceptAs<double>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<double>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, double>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<Guid>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for Guid.
public IRuleBuilderInitial<T, Guid> RuleFor(Expression<Func<T, ConceptAs<Guid>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<Guid>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, Guid>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<short>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for short.
public IRuleBuilderInitial<T, short> RuleFor(Expression<Func<T, ConceptAs<short>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<short>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, short>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<int>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for int.
public IRuleBuilderInitial<T, int> RuleFor(Expression<Func<T, ConceptAs<int>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<int>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, int>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<long>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for long.
public IRuleBuilderInitial<T, long> RuleFor(Expression<Func<T, ConceptAs<long>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<long>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, long>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<sbyte>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for sbyte.
public IRuleBuilderInitial<T, sbyte> RuleFor(Expression<Func<T, ConceptAs<sbyte>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<sbyte>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, sbyte>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<float>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for float.
public IRuleBuilderInitial<T, float> RuleFor(Expression<Func<T, ConceptAs<float>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<float>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, float>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<string>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for string.
public IRuleBuilderInitial<T, string> RuleFor(Expression<Func<T, ConceptAs<string>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<string>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, string>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<TimeOnly>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for TimeOnly.
public IRuleBuilderInitial<T, TimeOnly> RuleFor(Expression<Func<T, ConceptAs<TimeOnly>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<TimeOnly>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, TimeOnly>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<ushort>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for ushort.
public IRuleBuilderInitial<T, ushort> RuleFor(Expression<Func<T, ConceptAs<ushort>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<ushort>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, ushort>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<uint>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for uint.
public IRuleBuilderInitial<T, uint> RuleFor(Expression<Func<T, ConceptAs<uint>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<uint>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, uint>
- An IRuleBuilder instance on which validators can be defined. 
RuleFor(Expression<Func<T, ConceptAs<ulong>>>)
Defines a validation rules for a specific property based on ConceptAs<T> for ulong.
public IRuleBuilderInitial<T, ulong> RuleFor(Expression<Func<T, ConceptAs<ulong>>> expression)Parameters
- expressionExpression<Func<T, ConceptAs<ulong>>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, ulong>
- An IRuleBuilder instance on which validators can be defined. 
RuleForConcept<TProperty>(Expression<Func<T, TProperty>>)
Defines a validation rules for a property based on ConceptAs<T> for the actual concept type.
public IRuleBuilderInitial<T, TProperty> RuleForConcept<TProperty>(Expression<Func<T, TProperty>> expression)Parameters
- expressionExpression<Func<T, TProperty>>
- The expression representing the property to validate. 
Returns
- IRuleBuilderInitial<T, TProperty>
- An IRuleBuilder instance on which validators can be defined. 
Type Parameters
- TProperty
- Type of the concept. 
WhenCommand(Action)
Define a condition for when the context is a command.
public IConditionBuilder WhenCommand(Action callback)Parameters
- callbackAction
- Callback for defining the rules when it is a command. 
Returns
- IConditionBuilder
- FluentValidation.IConditionBuilder for building on the condition. 
WhenQuery(Action)
Define a condition for when the context is a command.
public IConditionBuilder WhenQuery(Action callback)Parameters
- callbackAction
- Callback for defining the rules when it is a command. 
Returns
- IConditionBuilder
- FluentValidation.IConditionBuilder for building on the condition.