Validator function for the "required" constraint.