def add_constraint(self, op, val):
if len(self.constraints) > <NUM_LIT:0>:<EOL><INDENT>if op.is_equality():<EOL><INDENT>clist = '<STR_LIT:U+002CU+0020>'.join(map(str, self.constraints))<EOL>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(self._field.name, clist))<EOL><DEDENT>elif op.is_exists():<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(self._field.name))<EOL><DEDENT><DEDENT>constraint = Constraint(self._field, op, val)<EOL>self.constraints.append(constraint)<EOL>if self._field.has_subfield():<EOL><INDENT>self._array = True<EOL><DEDENT>elif op.is_inequality():<EOL><INDENT>self._range = True<EOL><DEDENT>
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