Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit e183b35

Browse files
committed
feat: added NotBlank rule documentation
1 parent b312608 commit e183b35

2 files changed

Lines changed: 46 additions & 42 deletions

File tree

docs/03-rules-not-blank.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# NotBlank
2+
3+
Validates that a value is not equal to a blank string, blank array, `false` or `null`.
4+
5+
## Basic Usage
6+
7+
Bellow are the only cases where the rule will fail, everything else is considered valid
8+
(you may want to check the [`normalizer`](#normalizer) option for a different behaviour):
9+
10+
```php
11+
Validator::notBlank()->validate(''); // false
12+
Validator::notBlank()->validate([]); // false
13+
Validator::notBlank()->validate(false); // false
14+
Validator::notBlank()->validate(null); // false
15+
```
16+
17+
## Options
18+
19+
### `normalizer`
20+
21+
type: `callable` default: `null`
22+
23+
Allows to define a `callable` that will be applied to the value before checking if it is valid.
24+
25+
For example, use `trim`, or pass your own function, to now allow a string with whitespaces only:
26+
27+
```php
28+
// Existing PHP callables
29+
Validator::notBlank(normalizer: 'trim')->validate(' '); // false
30+
31+
// Function
32+
Validator::notBlank(normalizer: fn($value) => trim($value))->validate(' '); // false
33+
```
34+
35+
### `message`
36+
37+
type: `string` default: `The "{{ name }}" value should not be blank, "{{ value }}" given.`
38+
39+
Message that will be shown if the value is blank. Check the [Custom Messages]() section for more information.
40+
41+
The following parameters are available:
42+
43+
| Parameter | Description |
44+
|---------------|-----------------------------------|
45+
| `{{ value }}` | The current invalid value |
46+
| `{{ name }}` | Name of the value being validated |

docs/03-rules-notblank.md

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)