public static IsGreaterThanValidationResult CreateErrorResult <T>(T value, NumericBox <T> box) where T : struct, IFormattable, IComparable <T>, IConvertible, IEquatable <T> { if (box.MinValue == null) { var formatAndCulture = PleaseEnterAValueLessThanOrEqualToFormatAndCulture.GetOrCreate(box.Culture); var message = formatAndCulture.FormatMessage(box.MaxValue); return(new IsGreaterThanValidationResult( value: value, min: box.MinValue, max: box.MaxValue, currentBoxCulture: box.Culture, formatAndCulture: formatAndCulture, isValid: false, errorContent: message)); } else { var formatAndCulture = PleaseEnterAValueBetweenFormatAndCulture.GetOrCreate(box.Culture); var message = formatAndCulture.FormatMessage(box.MinValue, box.MaxValue); return(new IsGreaterThanValidationResult( value: value, min: box.MinValue, max: box.MaxValue, currentBoxCulture: box.Culture, formatAndCulture: formatAndCulture, isValid: false, errorContent: message)); } }
public static CanParseValidationResult CreateErrorResult <T>(string text, NumericBox <T> box) where T : struct, IFormattable, IComparable <T>, IConvertible, IEquatable <T> { var formatAndCulture = PleaseEnterAValidNumberFormatAndCulture.GetOrCreate(box.Culture); var message = formatAndCulture.Format; return(new CanParseValidationResult(typeof(T), text, box.Culture, formatAndCulture, false, message)); }
public static CanParseValidationResult CreateErrorResult <T>(string text, NumericBox <T> box) where T : struct, IFormattable, IComparable <T>, IConvertible, IEquatable <T> { if (box is null) { throw new ArgumentNullException(nameof(box)); } var formatAndCulture = PleaseEnterAValidNumberFormatAndCulture.GetOrCreate(box.Culture); var message = formatAndCulture.Format; return(new CanParseValidationResult( type: typeof(T), text: text, currentBoxCulture: box.Culture, formatAndCulture: formatAndCulture, isValid: false, errorContent: message)); }
public static RequiredButMissingValidationResult CreateErrorResult <T>(string text, NumericBox <T> box) where T : struct, IFormattable, IComparable <T>, IConvertible, IEquatable <T> { var formatAndCulture = DefaultFormatAndCulture.GetOrCreate(box.Culture); var message = formatAndCulture.Format; return(new RequiredButMissingValidationResult( type: typeof(T), text: text, currentBoxCulture: box.Culture, formatAndCulture: formatAndCulture, isValid: false, errorContent: message)); }