Download src/app/Rules/ExtensionCheckRule.php from pnacorp/xsender: direct link, hf CLI and curl.
- Browser
- Download file 923 Bytes
-
https://huggingface.co/pnacorp/xsender/resolve/main/src/app/Rules/ExtensionCheckRule.php
- Command line
-
hf download hf://pnacorp/xsender/src/app/Rules/ExtensionCheckRule.php
-
curl -L -o ExtensionCheckRule.php https://huggingface.co/pnacorp/xsender/resolve/main/src/app/Rules/ExtensionCheckRule.php
923 Bytes
| namespace App\Rules; | |
| use Illuminate\Contracts\Validation\Rule; | |
| class ExtensionCheckRule implements Rule | |
| { | |
| /** | |
| * Create a new rule instance. | |
| * | |
| * @return void | |
| */ | |
| public $extension; | |
| public function __construct(array $extension = ['csv','xlsx','xls','xlsb','xlsm']) | |
| { | |
| $this->extension = $extension; | |
| } | |
| /** | |
| * Determine if the validation rule passes. | |
| * | |
| * @param string $attribute | |
| * @param mixed $value | |
| * @return bool | |
| */ | |
| public function passes($attribute, $value) | |
| { | |
| if(in_array($value->getClientoriginalextension(),$this->extension)){ | |
| return true; | |
| } else{ | |
| return false; | |
| } | |
| } | |
| /** | |
| * Get the validation error message. | |
| * | |
| * @return string | |
| */ | |
| public function message() | |
| { | |
| return translate('The file format is invalid!! '); | |
| } | |
| } | |