private void checkUnit(Map<String, String> configToBeValidated, Stack stack, UnitValidatedProperty prop) {
    PropertyUnit stackUnit = PropertyUnit.of(stack, prop);
    PropertyValue value = PropertyValue.of(prop.getPropertyName(), configToBeValidated.get(prop.getPropertyName()));
    if (value.hasAnyUnit() && !value.hasUnit(stackUnit)) {
      throw new IllegalArgumentException("Property " + prop.getPropertyName() + "=" + value + " has an unsupported unit. Stack supported unit is: " + stackUnit + " or no unit");
    }
  }
I validate the unit of properties by checking if it matches to the stack defined unit.
Properties with different unit than the stack defined unit are rejected.
ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java