[Validator] Code property can't be populated to ConstraintViolation

This PR implements what is explained on #7273.