extracted all validation logic into a Validator