Skip to main content

PropertyValidatorOptions

Validator metadata.

Assembly: ServiceStack.dll
View Source
Declaration
public class PropertyValidatorOptions

Properties

Condition

Condition associated with the validator. If the condition fails, the validator will not run.

View Source
Declaration
[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
Declaration
[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
Declaration
public bool HasCondition { get; }

HasAsyncCondition

Whether or not this validator has an async condition associated with it.

View Source
Declaration
public bool HasAsyncCondition { get; }

CustomStateProvider

Function used to retrieve custom state for the validator

View Source
Declaration
public Func<PropertyValidatorContext, object> CustomStateProvider { get; set; }

SeverityProvider

Function used to retrieve the severity for the validator

View Source
Declaration
public Func<PropertyValidatorContext, Severity> SeverityProvider { get; set; }

ErrorCode

Retrieves the error code.

View Source
Declaration
public string ErrorCode { get; set; }

ErrorMessageSource

Retrieves the unformatted error message template.

View Source
Declaration
[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
Declaration
[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
Declaration
public void ApplyCondition(Func<PropertyValidatorContext, bool> condition)
Parameters
TypeName
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
Declaration
public void ApplyAsyncCondition(Func<PropertyValidatorContext, CancellationToken, Task<bool>> condition)
Parameters
TypeName
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
Declaration
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
Declaration
public string GetErrorMessageTemplate(PropertyValidatorContext context)
Returns

System.String: Either the formatted or unformatted error message.

Parameters
TypeNameDescription
ServiceStack.FluentValidation.Validators.PropertyValidatorContextcontextThe current property validator context.

|

SetErrorMessage(Func<PropertyValidatorContext, String>)

Sets the overridden error message template for this validator.

View Source
Declaration
public void SetErrorMessage(Func<PropertyValidatorContext, string> errorFactory)
Parameters
TypeNameDescription
System.Func<ServiceStack.FluentValidation.Validators.PropertyValidatorContext,System.String>errorFactoryA function for retrieving the error message template.

|

SetErrorMessage(String)

Sets the overridden error message template for this validator.

View Source
Declaration
public void SetErrorMessage(string errorMessage)
Parameters
TypeNameDescription
System.StringerrorMessageThe error message to set

|