/// <inheritdoc/> public override bool Validate(CsvValidationContext context, out string errorMessage) { errorMessage = string.Empty; if (IsEmpty(context.Value)) { errorMessage = CsvConfig.Current.ValidationMessage.GetRequiredError(context); return(false); } return(true); }
/// <inheritdoc/> public override bool Validate(CsvValidationContext context, out string errorMessage) { errorMessage = string.Empty; if (context.Value.Length <= this.maxLength) { return(true); } errorMessage = CsvConfig.Current.ValidationMessage.GetMaxLengthError(context, this.maxLength); return(false); }
/// <inheritdoc/> public override bool Validate(CsvValidationContext context, out string errorMessage) { errorMessage = string.Empty; if (string.IsNullOrEmpty(context.Value)) { return(true); } if (!Regex.IsMatch(context.Value, this.Pattern)) { errorMessage = GetErrorMessage(context); return(false); } return(true); }
/// <inheritdoc/> public override bool Validate(CsvValidationContext context, out string errorMessage) { errorMessage = string.Empty; if (!decimal.TryParse(context.Value, out decimal x)) { errorMessage = CsvConfig.Current.ValidationMessage.GetNumericConvertError(context); return(false); } if (HasPrecisionError(x, this.precision, this.scale)) { errorMessage = GetPrecisionErrorMessage(context); return(false); } if (HasOutOfRangeError(x)) { errorMessage = CsvConfig.Current.ValidationMessage.GetNumberOutOfRangeError(context, this.MinValueDecimal ?? 0, this.MaxValueDecimal ?? 0); return(false); } if (HasMinValueError(x)) { errorMessage = CsvConfig.Current.ValidationMessage.GetNumberMinValueError(context, this.MinValueDecimal ?? 0); return(false); } if (HasMaxValueError(x)) { errorMessage = CsvConfig.Current.ValidationMessage.GetNumberMaxValueError(context, this.MaxValueDecimal ?? 0); return(false); } return(true); }
/// <summary> /// 検証します。 /// </summary> /// <param name="context"><see cref="CsvValidationContext"/>。</param> /// <param name="errorMessage">エラーメッセージ。</param> /// <returns>検証成功の場合にtrue。</returns> public abstract bool Validate(CsvValidationContext context, out string errorMessage);