class LocationAttributeTypeValidator extends BaseAttributeTypeValidator<LocationAttributeType> {

	@Override
	public void validate(Object obj, Errors errors) {
		super.validate(obj, errors);
		LocationAttributeType locationObj = (LocationAttributeType) obj;
		LocationService ls = Context.getLocationService();
		if (locationObj.getName() != null && !locationObj.getName().isEmpty()) {
			LocationAttributeType loc = ls.getLocationAttributeTypeByName(locationObj.getName());
			if (loc != null && !loc.getUuid().equals(locationObj.getUuid())) {
				errors.rejectValue("name", "LocationAttributeType.error.nameAlreadyInUse");
			}
		} else {
			ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "LocationAttributeType.error.nameEmpty");
		}
		ValidateUtil.validateFieldLengths(errors, obj.getClass(), "name", "description", "datatypeClassname",
		    "preferredHandlerClassname", "retireReason");
	}

}