public function id(array $values)
    {
        $count = count($values);
        $ids = array_filter($values, 'ctype_digit');

        if ($count != count($ids)) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $existing = array_filter($values, function ($user_id) {
            if ($user_id == 0) {
                return true; // 0 also valid if we check that user is logged in
            }
            $user = $this->user->get($user_id);
            return isset($user['user_id']);
        });

        if ($count != count($existing)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('User')));
        }

        return true;
    }
public function id(array $values)
    {
        $count = count($values);
        $ids = array_filter($values, 'ctype_digit');

        if ($count != count($ids)) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $existing = array_filter($values, function ($user_id) {
            if ($user_id == 0) {
                return true; // 0 also valid if we check that user is logged in
            }
            $user = $this->user->get($user_id);
            return isset($user['user_id']);
        });

        if ($count != count($existing)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('User')));
        }

        return true;
    }
public function id ( array $ values ) { $ count = count ( $ values ) ; $ ids = array_filter ( $ values , 'ctype_digit' ) ; if ( $ count != count ( $ ids ) ) { return $ this -> translation -> text ( '@field has invalid value' , array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ) ; } $ existing = array_filter ( $ values , function ( $ user_id ) { if ( $ user_id == 0 ) { return true ; // 0 also valid if we check that user is logged in } $ user = $ this -> user -> get ( $ user_id ) ; return isset ( $ user [ 'user_id' ] ) ; } ) ; if ( $ count != count ( $ existing ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'User' ) ) ) ; } return true ; }
Validates the user ID condition
@param array $values
@return boolean|string
Validates the user ID condition