-
Notifications
You must be signed in to change notification settings - Fork 254
Upload validation #374
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
Upload validation #374
Conversation
Needs 100% test coverage, but I'm on board with the functionality. |
Getting there! |
… maxSize from ImageValidation to UploadValidation
|
||
.. code:: php | ||
|
||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the php open/close tags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how its done in 2.x: https://github.com/josegonzalez/cakephp-upload/blob/2.x/docs/validation.rst
Looks good, ship it. |
Started porting upload validation from the 2.x plugin.
It's a standalone validation provider which can optionally be loaded and used.
I've split it up into multiple traits to make it more manageable and give the option to add specific validations (video, pdf, ...) later.
Usage:
$validator->provider('upload', \Josegonzalez\Upload\Validation\UploadValidation::class);
If you only want to use the image validation rules:
$validator->provider('upload', \Josegonzalez\Upload\Validation\ImageValidation::class);
After this you can use it as:
$validator->add('file', 'filePhpUploadSize', [ 'rule' => 'isUnderPhpSizeLimit', 'message' => 'File is too large to upload', 'provider' => 'upload' ]);
If this code could makes it, i'll write some documentation for it.