Table of Contents

Class NumberValidator

Namespace
CloudyWing.FormValidators
Assembly
CloudyWing.FormValidators.dll

Validation constrains the number format of a value.

public sealed class NumberValidator : ComparableTypeValidator<decimal>, IFormValidator
Inheritance
NumberValidator
Implements
Inherited Members

Constructors

NumberValidator(string, string, bool, Func<string, string, decimal?, decimal?, string>)

Initializes a new instance of the NumberValidator class.

public NumberValidator(string column, string value, bool allowedThousands = false, Func<string, string, decimal?, decimal?, string> customErrorMessageAccessor = null)

Parameters

column string

The column.

value string

The value.

allowedThousands bool

if set to true [allowed thousands].

customErrorMessageAccessor Func<string, string, decimal?, decimal?, string>

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

NumberValidator(string, string, decimal?, decimal?, bool, Func<string, string, decimal?, decimal?, string>)

Initializes a new instance of the NumberValidator class.

public NumberValidator(string column, string value, decimal? min, decimal? max, bool allowedThousands = false, Func<string, string, decimal?, decimal?, string> customErrorMessageAccessor = null)

Parameters

column string

The column.

value string

The value.

min decimal?

The minimum.

max decimal?

The maximum.

allowedThousands bool

if set to true [allowed thousands].

customErrorMessageAccessor Func<string, string, decimal?, decimal?, string>

The custom error message accessor.

Properties

AllowedThousands

Gets a value indicating whether [allowed thousands].

public bool AllowedThousands { get; }

Property Value

bool

true if [allowed thousands]; otherwise, false.

CastErrorMessageAccessor

Gets the cast error message accessor.

protected override Func<string, string, string> CastErrorMessageAccessor { get; }

Property Value

Func<string, string, string>

The cast error message accessor.

Methods

TryParse(string, out decimal)

Tries the parse.

protected override bool TryParse(string value, out decimal result)

Parameters

value string

The value.

result decimal

The result.

Returns

bool

Parse value to type T result.