Refactored constraint validator.