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
columnstringThe column.
valuestringThe value.
allowedThousandsboolif set to
true[allowed thousands].customErrorMessageAccessorFunc<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
columnstringThe column.
valuestringThe value.
mindecimal?The minimum.
maxdecimal?The maximum.
allowedThousandsboolif set to
true[allowed thousands].customErrorMessageAccessorFunc<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
trueif [allowed thousands]; otherwise,false.
CastErrorMessageAccessor
Gets the cast error message accessor.
protected override Func<string, string, string> CastErrorMessageAccessor { get; }
Property Value
Methods
TryParse(string, out decimal)
Tries the parse.
protected override bool TryParse(string value, out decimal result)
Parameters
Returns
- bool
Parse value to type
Tresult.