class ValidateUtil {

	public static void validateFieldLengths(Errors errors, Class<?> aClass, String... fields) {
		if (disableValidation) {
			return;
		}

		Assert.notNull(errors, "Errors object must not be null");
		for (String field : fields) {
			Object value = errors.getFieldValue(field);
			if (value == null || !(value instanceof String)) {
				continue;
			}
			int length = Context.getAdministrationService().getMaximumPropertyLength((Class<? extends OpenmrsObject>) aClass, field);
			if (length == -1) {
				return;
			}
			if (((String) value).length() > length) {
				errors.rejectValue(field, "error.exceededMaxLengthOfField", new Object[] { length }, null);
			}
		}
	}

	private  ValidateUtil();

}