Skip to content

Commit

Permalink
Basic README file
Browse files Browse the repository at this point in the history
  • Loading branch information
bbprojectnet committed Feb 19, 2023
1 parent 3483a3d commit db21bb7
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Laravel rules

This package provides some additional validation rules for Laravel.

## Requirements

- PHP 8.1 and above
- Laravel 9 or 10

## Installation

Require this package with composer using the following command:

```bash
composer require bbprojectnet/laravel-rules
```

## Rules

### Base64

Checks whether the given string is a base 64 encoded string.

```php
return [
'attribute' => [new Base64()],
];
```

### EnumCase

Checks if the given string is one of the enum cases.

```php
return [
'attribute' => [new EnumCase(Color::class)], // any enum case
'attribute' => [new EnumCase([Color::Red, Color::Blue])], // selected enum cases
];
```

### Extension

Checks whether the given filename string has one of the allowed extensions.

```php
return [
'attribute' => [new Extension(['jpg', 'png', 'gif'])],
];
```

### ManyOf

Checks whether the values given in a string (separated, for example, by a comma) meet the specified rule.

```php
$rule = new Extension(['jpg', 'png']);

return [
'attribute' => [new ManyOf($rule)],
'attribute' => [(new ManyOf($rule))->delimeter('|')], // with custom delimeter
];
```

## License

The Laravel rules package is open-sourced software licensed under the MIT license.

0 comments on commit db21bb7

Please sign in to comment.