How do I validate an image field? #1212
-
So i'm using the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @backpack-operations To validate the image field in Backpack, you have a couple of options:
use Backpack\CRUD\app\Library\Validation\Rules\ValidUpload;
'image' => ValidUpload::field('required')
->file('file|mimes:jpeg,png,jpg,gif,svg|max:2048'), This rule allows you to define field rules and file rules separately, making it more convenient Docs > 6.x > Fields > FREE Field Types > upload.
This package provides validation rules specifically for base64 encoded images Github Issue: [Bug] The File/Image validation rule does not work on the Image field. It's worth noting that the Backpack team is working on improving the uploaders system, including validation, and they're considering creating a ValidationRule for the image field type in the future Github Issue: Image Validation. Remember, always ensure you're using the appropriate validation method for the specific field type you're working with in Backpack. Cheers. |
Beta Was this translation helpful? Give feedback.
Hello @backpack-operations
To validate the image field in Backpack, you have a couple of options:
upload
field type, Backpack provides a custom validation rule calledValidUpload
. This makes validation easier, especially when dealing with create and update operations. You can use it like this:This rule allows you to define field rules and file rules separately, making it more convenient Docs > 6.x > Fields > FREE Field Types > upload.
image
field type specifically, which sends a base64 string…