Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement list_exists validation rule #77

Open
DenTray opened this issue Jun 21, 2023 · 0 comments
Open

Implement list_exists validation rule #77

DenTray opened this issue Jun 21, 2023 · 0 comments
Assignees
Milestone

Comments

@DenTray
Copy link
Collaborator

DenTray commented Jun 21, 2023

To optimise the validation of list of values through the DB table, we need to implement custom validation rule.

How it should works:

public function rules(): array
{
    return [
        //will make `whereIn` query to determine which of values are not exists in DB
        'ids' => 'array|list_exists:users,id',
        'ids.*' => 'integer',

        //will works the same as in previous example but will find record in the `clients` table in `user_id` field and pluck `id` field from the input collection
        'users' => 'array|list_exists:clients,user_id,id',  
        'users.id' => 'integer'
    ];
}
@DenTray DenTray added this to the 2.4 milestone Jun 21, 2023
@DenTray DenTray modified the milestones: 2.4, 2.5 Nov 27, 2023
@DenTray DenTray modified the milestones: 2.5, 2.6 Dec 19, 2023
@DenTray DenTray assigned Adil9994 and unassigned Goodmain Dec 22, 2023
@DenTray DenTray modified the milestones: 2.6, 2.7 Mar 18, 2024
@DenTray DenTray assigned yogyrton and unassigned Adil9994 Mar 18, 2024
yogyrton pushed a commit that referenced this issue Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants