public function addRequiredFields($fields, ...$otherFields)
    {
        if(!is_array($fields)) {
            $fields = [$fields];
        }
        if(!empty($otherFields)) {
            $fields = array_merge($fields, $otherFields);
        }
        if (ArrayLib::is_associative($fields)) {
            foreach ($fields as $k => $v) {
                $constraint = Constraint_required::create();
                if ($v) {
                    $constraint->setMessage($v);
                }
                $this->setConstraint($k, $constraint);
            }
        } else {
            foreach ($fields as $field) {
                $this->setConstraint($field, Constraint_required::create());
            }
        }

        return $this;
    }
public function addRequiredFields($fields, ...$otherFields)
    {
        if(!is_array($fields)) {
            $fields = [$fields];
        }
        if(!empty($otherFields)) {
            $fields = array_merge($fields, $otherFields);
        }
        if (ArrayLib::is_associative($fields)) {
            foreach ($fields as $k => $v) {
                $constraint = Constraint_required::create();
                if ($v) {
                    $constraint->setMessage($v);
                }
                $this->setConstraint($k, $constraint);
            }
        } else {
            foreach ($fields as $field) {
                $this->setConstraint($field, Constraint_required::create());
            }
        }

        return $this;
    }
public function addRequiredFields ( $ fields , ... $ otherFields ) { if ( ! is_array ( $ fields ) ) { $ fields = [ $ fields ] ; } if ( ! empty ( $ otherFields ) ) { $ fields = array_merge ( $ fields , $ otherFields ) ; } if ( ArrayLib :: is_associative ( $ fields ) ) { foreach ( $ fields as $ k => $ v ) { $ constraint = Constraint_required :: create ( ) ; if ( $ v ) { $ constraint -> setMessage ( $ v ) ; } $ this -> setConstraint ( $ k , $ constraint ) ; } } else { foreach ( $ fields as $ field ) { $ this -> setConstraint ( $ field , Constraint_required :: create ( ) ) ; } } return $ this ; }
A quick way of adding required constraints to a number of fields

@param array $fieldNames - can be either indexed array of fieldnames, or associative array of fieldname => message
@param array $otherFields
@return this
A quick way of adding required constraints to a number of fields