<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_constraint(self, op, val):
 """Add new constraint. :param op: Constraint operator :type op: ConstraintOperator :param val: Constraint value :type val: str,Number :raise: ValueError if combination of constraints is illegal """

        if len(self.constraints) > 0:
            if op.is_equality():
                clist = ', '.join(map(str, self.constraints))
                raise ValueError('Field {}: equality operator cannot be combined '
                                 'with others: {}'.format(self._field.name, clist))
            elif op.is_exists():
                raise ValueError('Field {}: existence is implied '
                                 'by other operators'.format(self._field.name))
        constraint = Constraint(self._field, op, val)
        self.constraints.append(constraint)
        if self._field.has_subfield():
            self._array = True
        elif op.is_inequality():
            self._range = True