Try your search with a different keyword or use * as a wildcard.
using FluentValidation;
using FluentValidation.Validators;
namespace Nop.Web.Framework.Validators;
///
/// Decimal validator
///
public partial class DecimalPropertyValidator : PropertyValidator
{
protected readonly decimal _maxValue;
public override string Name => "DecimalPropertyValidator";
///
/// Ctor
///
/// Maximum value
public DecimalPropertyValidator(decimal maxValue)
{
_maxValue = maxValue;
}
///
/// Is valid?
///
/// Validation context
/// Result
public override bool IsValid(ValidationContext context, TProperty value)
{
if (decimal.TryParse(value.ToString(), out var propertyValue))
return Math.Round(propertyValue, 3) < _maxValue;
return false;
}
protected override string GetDefaultMessageTemplate(string errorCode) => "Decimal value is out of range";
}