Table of Contents

Class ValueLengthValidator

Namespace
CloudyWing.FormValidators
Assembly
CloudyWing.FormValidators.dll

Validation constraints a value does not exceed the length range.

public sealed class ValueLengthValidator : FormValidatorBase, IFormValidator
Inheritance
ValueLengthValidator
Implements
Inherited Members

Constructors

ValueLengthValidator(string, string, long, Func<string, string, long, long, string>)

Initializes a new instance of the ValueLengthValidator class.

public ValueLengthValidator(string column, string value, long max, Func<string, string, long, long, string> customErrorMessageAccessor = null)

Parameters

column string

The column.

value string

The value.

max long

The maximum.

customErrorMessageAccessor Func<string, string, long, long, string>

The custom error message accessor. The arguments are column, value, min, max.

ValueLengthValidator(string, string, long, long, Func<string, string, long, long, string>)

Initializes a new instance of the ValueLengthValidator class.

public ValueLengthValidator(string column, string value, long min, long max, Func<string, string, long, long, string> customErrorMessageAccessor = null)

Parameters

column string

The column.

value string

The value.

min long

The minimum. Less than or equal to 0 means unlimited.

max long

The maximum. Less than or equal to 0 means unlimited.

customErrorMessageAccessor Func<string, string, long, long, string>

The custom error message accessor. The arguments are column, value, min, max.

Properties

CustomErrorMessage

Gets the custom error message.

protected override string CustomErrorMessage { get; }

Property Value

string

The custom error message.

CustomErrorMessageAccessor

Gets the custom range message format.

public Func<string, string, long, long, string> CustomErrorMessageAccessor { get; set; }

Property Value

Func<string, string, long, long, string>

The custom range message format.

DefaultErrorMessage

Gets the default error message.

protected override string DefaultErrorMessage { get; }

Property Value

string

The default error message.

HasCustomErrorMessage

Gets a value indicating whether this instance has custom error message.

protected override bool HasCustomErrorMessage { get; }

Property Value

bool

true if this instance has custom error message; otherwise, false.

MaxLength

Gets the maximum length.

public long MaxLength { get; }

Property Value

long

The maximum length.

MinLength

Gets the minimum length.

public long MinLength { get; }

Property Value

long

The minimum length.

Methods

ValidateValue()

Validates the value.

protected override bool ValidateValue()

Returns

bool

The validation result.

See Also