classify admin
This commit is contained in:
15
app/Rules/JsonFile.php
Normal file
15
app/Rules/JsonFile.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class JsonFile implements ValidationRule {
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void {
|
||||
if (($value instanceof \Illuminate\Http\UploadedFile) && $value->getClientOriginalExtension() != 'json' && !in_array($value->getMimeType(), ["application/json", "text/plain"])) {
|
||||
$fail($attribute . ' must be a json file');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user