protected function validateCodeLanguage()
    {
        $field = 'code';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Code');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (preg_match('/^[A-Za-z\\-]+$/', $value) !== 1) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $updating = $this->getUpdating();

        if (isset($updating['code']) && $updating['code'] === $value) {
            return true;
        }

        $language = $this->language->get($value);

        if (!empty($language)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        return true;
    }
protected function validateCodeLanguage()
    {
        $field = 'code';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Code');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (preg_match('/^[A-Za-z\\-]+$/', $value) !== 1) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $updating = $this->getUpdating();

        if (isset($updating['code']) && $updating['code'] === $value) {
            return true;
        }

        $language = $this->language->get($value);

        if (!empty($language)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        return true;
    }
protected function validateCodeLanguage ( ) { $ field = 'code' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Code' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( preg_match ( '/^[A-Za-z\\-]+$/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ value ) { return true ; } $ language = $ this -> language -> get ( $ value ) ; if ( ! empty ( $ language ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
Validates a language code
@return boolean|null
Validates a language code