Skip to content

Commit cb47203

Browse files
Gummibeergitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent c95b889 commit cb47203

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

docs/package/validation-rule-factory.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ If you want to validate translated attributes it could get quite complex to list
44

55
```php
66
$rules = [
7-
'title' => 'required',
8-
'translations.%content%.body' => 'required',
7+
'translations.%title%' => 'sometimes|string',
8+
'translations.%content%' => ['required_with:translations.%title%', 'string'],
99
];
1010

1111
RuleFactory::make($rules);
1212
```
1313

14-
This will return an array which adjusted the `translations.%content%.body` key to match your configured key format. The result will be:
14+
This will return an array which adjusted the placeholder in key and string value or array with strings to match your configured key format. The result will be:
1515

1616
```php
1717
[
18-
'title' => 'required',
19-
'translations.en.content.body' => 'required',
20-
'translations.de.content.body' => 'required',
21-
'translations.de-DE.content.body' => 'required',
22-
'translations.de-AT.content.body' => 'required',
18+
'translations.en.title' => 'sometimes|string',
19+
'translations.de.title' => 'sometimes|string',
20+
'translations.de-DE.title' => 'sometimes|string',
21+
'translations.de-AT.title' => 'sometimes|string',
22+
23+
'en.content' => ['required_with:translations.en.title', 'string'],
24+
'de.content' => ['required_with:translations.de.title', 'string'],
25+
'de-DE.content' => ['required_with:translations.de-DE.title', 'string'],
26+
'de-AT.content' => ['required_with:translations.de-AT.title', 'string'],
2327
]
2428
```
2529

@@ -49,6 +53,10 @@ This will create the dot-notation to support locale sub-arrays. `en.content`.
4953

5054
This will create the colon separated style. `content:en`
5155

56+
{% hint style="info" %}
57+
If you use the key format and want to use use it as argument for a rule you have to wrap it in quotes. `required_with:"translations.content:en"`
58+
{% endhint %}
59+
5260
### Runtime
5361

5462
For sure you can change the default `format`, `prefix`, `suffix` and applied `locales` during runtime. To do so only pass them as parameter to the `make()` method.

0 commit comments

Comments
 (0)