IncludeRule<T>
Include rule
Assembly: ServiceStack.dll
View Source
public class IncludeRule<T> : PropertyRule, IValidationRule, IIncludeRule
Inherited Properties
AsyncCondition
Asynchronous condition for all validators in this rule.
View Source
[Obsolete("This property will not be accessible in FluentValidation 10. Use HasCondition/HasAsyncCondition to check if the rule has a condition defined")]
public Func<IValidationContext, CancellationToken, Task<bool>> AsyncCondition { get; }
CascadeMode
Cascade mode for this rule.
View Source
public CascadeMode CascadeMode { get; set; }
Condition
Condition for all validators in this rule.
View Source
[Obsolete("This property will not be accessible in FluentValidation 10. Use HasCondition/HasAsyncCondition to check if the rule has a condition defined")]
public Func<IValidationContext, bool> Condition { get; }
CurrentValidator
The current validator being configured by this rule.
View Source
public IPropertyValidator CurrentValidator { get; }
DependentRules
Dependent rules
View Source
public List<IValidationRule> DependentRules { get; }
DisplayName
String source that can be used to retrieve the display name (if null, falls back to the property name)
View Source
[Obsolete("This property is deprecated and will be removed in FluentValidation 10. Use the GetDisplayName and SetDisplayName instead.")]
public IStringSource DisplayName { get; set; }
Expression
Expression that was used to create the rule.
View Source
public LambdaExpression Expression { get; }
HasAsyncCondition
Checks whether this rule has an async condition defined.
View Source
public bool HasAsyncCondition { get; }
HasCondition
Checks whether this rule has a condition defined.
View Source
public bool HasCondition { get; }
Member
Property associated with this rule.
View Source
public MemberInfo Member { get; }
MessageBuilder
Allows custom creation of an error message
View Source
public Func<MessageBuilderContext, string> MessageBuilder { get; set; }
OnFailure
Function that will be invoked if any of the validators associated with this rule fail.
View Source
public Action<object, IEnumerable<ValidationFailure>> OnFailure { get; set; }
PropertyFunc
Function that can be invoked to retrieve the value of the property.
View Source
public Func<object, object> PropertyFunc { get; }
PropertyName
Returns the property name for the property being validated. Returns null if it is not a property being validated (eg a method call)
View Source
public string PropertyName { get; set; }
RuleSets
Rule set that this rule belongs to (if specified)
View Source
public string[] RuleSets { get; set; }
Transformer
View Source
[Obsolete("This property will be removed in FluentValidation 10")]
public Func<object, object> Transformer { get; set; }
TypeToValidate
Type of the property being validated
View Source
public Type TypeToValidate { get; }
Validators
Validators associated with this rule.
View Source
public IEnumerable<IPropertyValidator> Validators { get; }
Methods
Create(IValidator<T>, Func<CascadeMode>)
Creates a new include rule from an existing validator
View Source
public static IncludeRule<T> Create(IValidator<T> validator, Func<CascadeMode> cascadeModeThunk)
Returns
ServiceStack.FluentValidation.Internal.IncludeRule<T>
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.IValidator<T> | validator |
System.Func<ServiceStack.FluentValidation.CascadeMode> | cascadeModeThunk |
Create<TValidator>(Func<T, TValidator>, Func<CascadeMode>)
Creates a new include rule from an existing validator
View Source
public static IncludeRule<T> Create<TValidator>(Func<T, TValidator> func, Func<CascadeMode> cascadeModeThunk)
where TValidator : IValidator<T>
Returns
ServiceStack.FluentValidation.Internal.IncludeRule<T>
Parameters
Type | Name |
---|---|
System.Func<<T>,<TValidator>> | func |
System.Func<ServiceStack.FluentValidation.CascadeMode> | cascadeModeThunk |
Type Parameters
TValidator
Validate(IValidationContext)
View Source
public override IEnumerable<ValidationFailure> Validate(IValidationContext context)
Returns
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.IValidationContext | context |
ValidateAsync(IValidationContext, CancellationToken)
View Source
public override async Task<IEnumerable<ValidationFailure>> ValidateAsync(IValidationContext context, CancellationToken cancellation)
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>>
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.IValidationContext | context |
System.Threading.CancellationToken | cancellation |
Inherited Methods
AddValidator(IPropertyValidator)
Adds a validator to the rule.
View Source
public void AddValidator(IPropertyValidator validator)
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.Validators.IPropertyValidator | validator |
ApplyAsyncCondition(Func<PropertyValidatorContext, CancellationToken, Task<Boolean>>, ApplyConditionTo)
Applies the condition to the rule asynchronously
View Source
public void ApplyAsyncCondition(Func<PropertyValidatorContext, CancellationToken, Task<bool>> predicate, ApplyConditionTo applyConditionTo = ApplyConditionTo.AllValidators)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.FluentValidation.Validators.PropertyValidatorContext,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Boolean>> | predicate |
ServiceStack.FluentValidation.ApplyConditionTo | applyConditionTo |
ApplyCondition(Func<PropertyValidatorContext, Boolean>, ApplyConditionTo)
Applies a condition to the rule
View Source
public void ApplyCondition(Func<PropertyValidatorContext, bool> predicate, ApplyConditionTo applyConditionTo = ApplyConditionTo.AllValidators)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.FluentValidation.Validators.PropertyValidatorContext,System.Boolean> | predicate |
ServiceStack.FluentValidation.ApplyConditionTo | applyConditionTo |
ApplySharedAsyncCondition(Func<IValidationContext, CancellationToken, Task<Boolean>>)
View Source
public void ApplySharedAsyncCondition(Func<IValidationContext, CancellationToken, Task<bool>> condition)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.FluentValidation.IValidationContext,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Boolean>> | condition |
ApplySharedCondition(Func<IValidationContext, Boolean>)
View Source
public void ApplySharedCondition(Func<IValidationContext, bool> condition)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.FluentValidation.IValidationContext,System.Boolean> | condition |
ClearValidators()
Clear all validators from this rule.
View Source
public void ClearValidators()
Create<T, TProperty>(Expression<Func<T, TProperty>>)
Creates a new property rule from a lambda expression.
View Source
public static PropertyRule Create<T, TProperty>(Expression<Func<T, TProperty>> expression)
Returns
ServiceStack.FluentValidation.Internal.PropertyRule
Parameters
Type | Name |
---|---|
System.Linq.Expressions.Expression<System.Func<<T>,<TProperty>>> | expression |
Type Parameters
T
TProperty
Create<T, TProperty>(Expression<Func<T, TProperty>>, Func<CascadeMode>, Boolean)
Creates a new property rule from a lambda expression.
View Source
public static PropertyRule Create<T, TProperty>(Expression<Func<T, TProperty>> expression, Func<CascadeMode> cascadeModeThunk, bool bypassCache = false)
Returns
ServiceStack.FluentValidation.Internal.PropertyRule
Parameters
Type | Name |
---|---|
System.Linq.Expressions.Expression<System.Func<<T>,<TProperty>>> | expression |
System.Func<ServiceStack.FluentValidation.CascadeMode> | cascadeModeThunk |
System.Boolean | bypassCache |
Type Parameters
T
TProperty
GetDisplayName()
Display name for the property.
View Source
[Obsolete("Calling GetDisplayName without a context parameter is deprecated and will be removed in FluentValidation 10. If you really need this behaviour, you can call the overload that takes a context but pass in null.")]
public string GetDisplayName()
Returns
System.String
GetDisplayName(ICommonContext)
Display name for the property.
View Source
public string GetDisplayName(ICommonContext context)
Returns
System.String
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.ICommonContext | context |
InvokePropertyValidator(IValidationContext, IPropertyValidator, String)
Invokes a property validator using the specified validation context.
View Source
protected virtual IEnumerable<ValidationFailure> InvokePropertyValidator(IValidationContext context, IPropertyValidator validator, string propertyName)
Returns
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.IValidationContext | context |
ServiceStack.FluentValidation.Validators.IPropertyValidator | validator |
System.String | propertyName |
InvokePropertyValidatorAsync(IValidationContext, IPropertyValidator, String, CancellationToken)
Invokes the validator asynchronously
View Source
protected virtual async Task<IEnumerable<ValidationFailure>> InvokePropertyValidatorAsync(IValidationContext context, IPropertyValidator validator, string propertyName, CancellationToken cancellation)
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>>
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.IValidationContext | context |
ServiceStack.FluentValidation.Validators.IPropertyValidator | validator |
System.String | propertyName |
System.Threading.CancellationToken | cancellation |
RemoveValidator(IPropertyValidator)
Remove a validator in this rule.
View Source
public void RemoveValidator(IPropertyValidator original)
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.Validators.IPropertyValidator | original |
ReplaceValidator(IPropertyValidator, IPropertyValidator)
Replaces a validator in this rule. Used to wrap validators.
View Source
public void ReplaceValidator(IPropertyValidator original, IPropertyValidator newValidator)
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.Validators.IPropertyValidator | original |
ServiceStack.FluentValidation.Validators.IPropertyValidator | newValidator |
SetDisplayName(Func<IValidationContext, String>)
Sets the display name for the property using a function.
View Source
public void SetDisplayName(Func<IValidationContext, string> factory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ServiceStack.FluentValidation.IValidationContext,System.String> | factory | The function for building the display name |
|
SetDisplayName(String)
Sets the display name for the property.
View Source
public void SetDisplayName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The property's display name |
|
Validate(IValidationContext)
Performs validation using a validation context and returns a collection of Validation Failures.
View Source
public virtual IEnumerable<ValidationFailure> Validate(IValidationContext context)
Returns
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>
: A collection of validation failures
Parameters
Type | Name | Description |
---|---|---|
ServiceStack.FluentValidation.IValidationContext | context | Validation Context |
|
ValidateAsync(IValidationContext, CancellationToken)
Performs asynchronous validation using a validation context and returns a collection of Validation Failures.
View Source
public virtual async Task<IEnumerable<ValidationFailure>> ValidateAsync(IValidationContext context, CancellationToken cancellation)
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>>
: A collection of validation failures
Parameters
Type | Name | Description |
---|---|---|
ServiceStack.FluentValidation.IValidationContext | context | Validation Context |
|
| System.Threading.CancellationToken
| cancellation |
|