thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Action-specific validation rules #2034

Closed gausam closed 5 years ago

gausam commented 7 years ago

Description:

Currently, any defined validation rules will apply to all the major actions (store and update).

This premise breaks when for example we have a Logo field which is required when creating a new record, but is optional when updating the record (because the initial image provided will still be on file). So with the current mechanisms, the user will ALWAYS be asked by Voyager to re-upload the image each time they want to update anything else.

The user profile editing in Voyager avoids this scenarios because of the default avatar mechanism, but the same mechanism is not always an option.

Steps To Reproduce:

Proposal

I propose a mechanism for allowing the universal validation rules we have at the moment, but also a way to define action-specific validation rules. In terms of validation rules, the above would have been easily solved if there was a way to "require" the image when creating and then just having plain "image" checking in the validation rule (without "require") when updating.

Briefly ran it past @marktopper on Slack, and have a preliminary nod from him.

Solution is rather simple (as you'll see in PR #2035), and the use case is quite common in any app, I'd imagine.

sineld commented 7 years ago

+1

gausam commented 7 years ago

@fletch3555 Interested to know what your thoughts are regarding the above issue & its PR. Currently running this in production.

madzimai commented 6 years ago

This is a really critical issue for us as well. We're about to launch in a few days what's probably going to be the largest deployment of Voyager I can think of (international enterprise org), and this is one of the blockers we're dealing with right now.

@samtheson Have you asked @fletch3555 or @marktopper on Slack to review the issue & PR? I think if you present the case to them they may push this up a bit.

emptynick commented 5 years ago

This will be possible in version 1.2 (#3909) commit https://github.com/the-control-group/voyager/pull/3909/commits/53b6036a034611334b4659c8bbb864349e490851.

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.