PropertyValidatorOptions
Validator metadata.
Assembly: ServiceStack.dll
View Source
public class PropertyValidatorOptions
Properties
Condition
Condition associated with the validator. If the condition fails, the validator will not run.
View Source
[Obsolete("The Condition property will not be accessible in FluentValidation 10. Use the HasCondition property to check if a condition is set.")]
public Func<PropertyValidatorContext, bool> Condition { get; }
AsyncCondition
Async condition associated with the validator. If the condition fails, the validator will not run.
View Source
[Obsolete("The AsyncCondition property will not be accessible in FluentValidation 10. Use the HasAsyncCondition property to check if a condition is set.")]
public Func<PropertyValidatorContext, CancellationToken, Task<bool>> AsyncCondition { get; }
HasCondition
Whether or not this validator has a condition associated with it.
View Source
public bool HasCondition { get; }
HasAsyncCondition
Whether or not this validator has an async condition associated with it.
View Source
public bool HasAsyncCondition { get; }
CustomStateProvider
Function used to retrieve custom state for the validator
View Source
public Func<PropertyValidatorContext, object> CustomStateProvider { get; set; }
SeverityProvider
Function used to retrieve the severity for the validator
View Source
public Func<PropertyValidatorContext, Severity> SeverityProvider { get; set; }
ErrorCode
Retrieves the error code.
View Source
public string ErrorCode { get; set; }
ErrorMessageSource
Retrieves the unformatted error message template.
View Source
[Obsolete("ErrorMessageSource is deprecated and will be removed in FluentValidation 10. Please use SetErrorMessage and GetErrorMessageTemplate instead.")]
public IStringSource ErrorMessageSource { get; set; }
ErrorCodeSource
Retrieves the error code.
View Source
[Obsolete("ErrorCodeSource is deprecated and will be removed FluentValidation 10. Please use the ErrorCode property instead.")]
public IStringSource ErrorCodeSource { get; set; }
Methods
ApplyCondition(Func<PropertyValidatorContext, Boolean>)
Adds a condition for this validator. If there's already a condition, they're combined together with an AND.
View Source
public void ApplyCondition(Func<PropertyValidatorContext, bool> condition)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.FluentValidation.Validators.PropertyValidatorContext,System.Boolean> | condition |
ApplyAsyncCondition(Func<PropertyValidatorContext, CancellationToken, Task<Boolean>>)
Adds a condition for this validator. If there's already a condition, they're combined together with an AND.
View Source
public void ApplyAsyncCondition(Func<PropertyValidatorContext, CancellationToken, Task<bool>> condition)
Parameters
Type | Name |
---|---|
System.Func<ServiceStack.FluentValidation.Validators.PropertyValidatorContext,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Boolean>> | condition |
GetDefaultMessageTemplate()
Returns the default error message template for this validator, when not overridden.
View Source
protected virtual string GetDefaultMessageTemplate()
Returns
System.String
GetErrorMessageTemplate(PropertyValidatorContext)
Gets the error message. If a context is supplied, it will be used to format the message if it has placeholders. If no context is supplied, the raw unformatted message will be returned, containing placeholders.
View Source
public string GetErrorMessageTemplate(PropertyValidatorContext context)
Returns
System.String
: Either the formatted or unformatted error message.
Parameters
Type | Name | Description |
---|---|---|
ServiceStack.FluentValidation.Validators.PropertyValidatorContext | context | The current property validator context. |
|
SetErrorMessage(Func<PropertyValidatorContext, String>)
Sets the overridden error message template for this validator.
View Source
public void SetErrorMessage(Func<PropertyValidatorContext, string> errorFactory)
Parameters
Type | Name | Description |
---|---|---|
System.Func<ServiceStack.FluentValidation.Validators.PropertyValidatorContext,System.String> | errorFactory | A function for retrieving the error message template. |
|
SetErrorMessage(String)
Sets the overridden error message template for this validator.
View Source
public void SetErrorMessage(string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
System.String | errorMessage | The error message to set |
|