Infrastructure/BaseEntity/DatabaseTable/Model/DatabaseTableFormValidator.php
protected function setRules(bool $skipUniqueForUnchanged = false, array $record = null)
    {
        $this->mapFieldsRules($this->databaseTableValidation->getValidationRules());

        $uniqueColumns = $this->mapper->getUniqueColumns();

        if (count($uniqueColumns) > 0) {
            $this->addUniqueRule();

            foreach ($uniqueColumns as $databaseColumnMapper) {
                $field = $databaseColumnMapper->getName();
                // only set rule for changed columns if $skipUniqueForUnchanged is set true
                if ( !($skipUniqueForUnchanged && $this->inputData[$field] == $record[$field]) ) {
                    $this->rule('unique', $field, $databaseColumnMapper, $this);
                }
            }
        }
    }
protected function setRules(bool $skipUniqueForUnchanged = false, array $record = null)
    {
        $this->mapFieldsRules($this->databaseTableValidation->getValidationRules());

        $uniqueColumns = $this->mapper->getUniqueColumns();

        if (count($uniqueColumns) > 0) {
            $this->addUniqueRule();

            foreach ($uniqueColumns as $databaseColumnMapper) {
                $field = $databaseColumnMapper->getName();
                // only set rule for changed columns if $skipUniqueForUnchanged is set true
                if ( !($skipUniqueForUnchanged && $this->inputData[$field] == $record[$field]) ) {
                    $this->rule('unique', $field, $databaseColumnMapper, $this);
                }
            }
        }
    }
protected function setRules ( bool $ skipUniqueForUnchanged = false , array $ record = null ) { $ this -> mapFieldsRules ( $ this -> databaseTableValidation -> getValidationRules ( ) ) ; $ uniqueColumns = $ this -> mapper -> getUniqueColumns ( ) ; if ( count ( $ uniqueColumns ) > 0 ) { $ this -> addUniqueRule ( ) ; foreach ( $ uniqueColumns as $ databaseColumnMapper ) { $ field = $ databaseColumnMapper -> getName ( ) ; // only set rule for changed columns if $skipUniqueForUnchanged is set true if ( ! ( $ skipUniqueForUnchanged && $ this -> inputData [ $ field ] == $ record [ $ field ] ) ) { $ this -> rule ( 'unique' , $ field , $ databaseColumnMapper , $ this ) ; } } } }
called by both insert and update children. update will call with skip true and record data so that only columns that have been changed have the unique rule applied, otherwise validation would fail for unchanged unique fields
called by both insert and update children . update will call with skip true and record data so that only columns that have been changed have the unique rule applied otherwise validation would fail for unchanged unique fields