Skip to content

Commit 9139590

Browse files
authored
add DB validation rule info to readme (#95)
1 parent 9bb6f69 commit 9139590

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ User::with('role')->first();
9898

9999
> Note: There is one caveat when dealing with Sushi model relationships. The `whereHas` method will NOT work. This is because the two models are spread across two separate databases.
100100
101+
### Using database-checking validation rules
102+
You can even use Laravel's `exists:table,column` database checking request validation rule.
103+
104+
```php
105+
$data = request()->validate([
106+
'state' => ['required', 'exists:App\Model\State,abbr'],
107+
]);
108+
```
109+
110+
> Note: Be aware that you must use the fully-qualified namespace of the model instead of a table name. This ensures that Laravel will correctly resolve the model's connection.
111+
101112
### Custom Schema
102113
If Sushi's schema auto-detection system doesn't meet your specific requirements for the supplied row data, you can customize them with the `$schema` property or the `getSchema()` method.
103114

0 commit comments

Comments
 (0)