/// <summary> /// Validates the format of the given string value /// </summary> /// <param name = "value">Value to validate</param> /// <returns>true if valid, false otherwise</returns> public bool IsValid(string value) { var first = value[0]; if (first != 'C' && first != 'D') { return(false); } var numeric = new NumericFieldValidator(); return(numeric.IsValid(value.Substring(1))); }
private void validateSpecificFieldValuesMatchesFieldType(List <SpecificFieldValueDTO> values) { foreach (SpecificFieldValueDTO specificFieldValue in values) { if (unitOfWork.SupplierFieldRepository.GetByID(specificFieldValue.IdSupplierField) != null) { ITypeValidator validator; SupplierField supplierField = unitOfWork.SupplierFieldRepository.GetByID(specificFieldValue.IdSupplierField); SupplierFieldType fieldType = (SupplierFieldType)Enum.Parse(typeof(SupplierFieldType), supplierField.TypeOfField, true); switch (fieldType) { case (SupplierFieldType.Text): { break; } case (SupplierFieldType.Numeric): { validator = new NumericFieldValidator(); validator.validateTypeMatchesGivenValue(specificFieldValue.Value); break; } case (SupplierFieldType.Date): { validator = new DateFieldValidator(); validator.validateTypeMatchesGivenValue(specificFieldValue.Value); break; } } } else { throw new WrongDataTypeException("Datos mal ingresados"); } } }
/// <summary> /// Numeric validator /// </summary> /// <param name = "value">Value to validate</param> /// <returns>true if valid, false otherwise</returns> public static bool IsNumeric(string value) { var v = new NumericFieldValidator(); return(v.IsValid(value)); }