Skip to content

Commit

Permalink
Added clean file directive.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Robert committed Mar 4, 2022
1 parent bfd8021 commit 7ace6df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Chase/Helga/Executioner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ace6df

Please sign in to comment.