Created
December 18, 2016 06:55
-
-
Save emsifa/ba24b099caf2955283460cad91d5f61f to your computer and use it in GitHub Desktop.
Test UploadedFileRule for Rakit Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('vendor/autoload.php'); | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
$validator = new Rakit\Validation\Validator; | |
$validation_1 = $validator->validate($_FILES, [ | |
'file' => 'required|uploaded_file' | |
]); | |
// manually passing array | |
$validation_2 = $validator->validate([ | |
'file' => [ | |
'name' => 'foo.txt', | |
'type' => 'image/jpeg', | |
'size' => 1000, | |
'tmp_name' => __FILE__, | |
'error' => UPLOAD_ERR_OK | |
] | |
], [ | |
'file' => 'required|uploaded_file' | |
]); | |
echo "<pre>"; | |
var_dump([ | |
'validation_1' => $validation_1->errors()->all(), | |
'validation_2' => $validation_2->errors()->all() | |
]); | |
echo "</pre>"; | |
} | |
?> | |
<form method='POST' enctype='multipart/form-data'> | |
<input type='file' name='file'> | |
<button>Submit</button> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool