protected function validate()
    {
        $valid = parent::validate();

        if ($this->CanViewType == 'OnlyTheseUsers' && !$this->ViewerGroups()->count()) {
            $valid->error(
                _t(
                    'DMSDocument.VALIDATIONERROR_NOVIEWERSELECTED',
                    "Selecting 'Only these people' from a viewers list needs at least one group selected."
                )
            );
        }

        if ($this->CanEditType == 'OnlyTheseUsers' && !$this->EditorGroups()->count()) {
            $valid->error(
                _t(
                    'DMSDocument.VALIDATIONERROR_NOEDITORSELECTED',
                    "Selecting 'Only these people' from a editors list needs at least one group selected."
                )
            );
        }

        return $valid;
    }
protected function validate()
    {
        $valid = parent::validate();

        if ($this->CanViewType == 'OnlyTheseUsers' && !$this->ViewerGroups()->count()) {
            $valid->error(
                _t(
                    'DMSDocument.VALIDATIONERROR_NOVIEWERSELECTED',
                    "Selecting 'Only these people' from a viewers list needs at least one group selected."
                )
            );
        }

        if ($this->CanEditType == 'OnlyTheseUsers' && !$this->EditorGroups()->count()) {
            $valid->error(
                _t(
                    'DMSDocument.VALIDATIONERROR_NOEDITORSELECTED',
                    "Selecting 'Only these people' from a editors list needs at least one group selected."
                )
            );
        }

        return $valid;
    }
protected function validate ( ) { $ valid = parent :: validate ( ) ; if ( $ this -> CanViewType == 'OnlyTheseUsers' && ! $ this -> ViewerGroups ( ) -> count ( ) ) { $ valid -> error ( _t ( 'DMSDocument.VALIDATIONERROR_NOVIEWERSELECTED' , "Selecting 'Only these people' from a viewers list needs at least one group selected." ) ) ; } if ( $ this -> CanEditType == 'OnlyTheseUsers' && ! $ this -> EditorGroups ( ) -> count ( ) ) { $ valid -> error ( _t ( 'DMSDocument.VALIDATIONERROR_NOEDITORSELECTED' , "Selecting 'Only these people' from a editors list needs at least one group selected." ) ) ; } return $ valid ; }
Checks at least one group is selected if CanViewType || CanEditType == 'OnlyTheseUsers'

@return ValidationResult
Checks at least one group is selected if CanViewType || CanEditType == OnlyTheseUsers