diff --git a/Chase/Helga/Executioner.php b/Chase/Helga/Executioner.php index 4930b55..87f744f 100644 --- a/Chase/Helga/Executioner.php +++ b/Chase/Helga/Executioner.php @@ -315,6 +315,15 @@ public static function fileImage($target, $key = null) }, $key); } + public static function file($target, $key = null) + { + return self::exec(function () use ($target) { + return (!rawContainsCode($target)); + }, function ($r) use ($key) { + $r->message = sprintf("%s must not contain php code.", ucwords($key ?? 'File')); + }, $key); + } + public static function filePdf($target, $key = null) { return self::exec(function () use ($target) { diff --git a/docs/rules.md b/docs/rules.md index 2a8dc01..9d78e6e 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -255,6 +255,13 @@ $path = '/files/image.png'; $v = validate($path)->withRules(['fileImage']); ``` +`file` +Ensures the file at the path passed does not contain any php code. +```php +$path = '/files/pdf.pdf'; +$v = validate($path)->withRules(['file']); +``` + `filePdf` The path passed must point to a valid pdf file. ```php