Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions content/collections/docs/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ You may use any validation rule provided by Laravel. You can view the complete l
handle: highlander
field:
type: text
validate: 'unique_entry_value:{collection},{id},{site}'
validate: 'new \Statamic\Rules\UniqueEntryValue({collection}, {id}, {site})'
```

This works like Laravel's `unique` validation rule, but for Statamic entries. The rule should be used verbatim as shown above. Statamic will replace the `collection`, `id`, and `site` behind the scenes.
Expand All @@ -120,10 +120,10 @@ You can then customize the error message right in your `resources/lang/{lang}/va
handle: foo
field:
type: text
validate: 'unique_term_value:{taxonomy},{id},{site}'
validate: 'new \Statamic\Rules\UniqueTermValue({taxonomy}, {id}, {site})'
```

This works like the `unique_entry_value` rule, but for taxonomy terms.
This works like the `UniqueEntryValue` rule, but for taxonomy terms.

### Unique User Value

Expand All @@ -132,13 +132,13 @@ This works like the `unique_entry_value` rule, but for taxonomy terms.
handle: login
field:
type: text
validate: 'unique_user_value:{id}'
validate: 'new \Statamic\Rules\UniqueUserValue({id})'
```

This works like the `unique_entry_value` rule, but for users.
This works like the `UniqueEntryValue` rule, but for users.

:::tip
If you want to override the field that is being validated (e.g. in Livewire Form Objects), you can do so by passing a second parameter to the validation rule, such as `unique_user_value:{id},username`.
If you want to override the field that is being validated (e.g. in Livewire Form Objects), you can do so by passing a second parameter to the validation rule, such as `new \Statamic\Rules\UniqueUserValue({id}, "username")`.
:::

## Custom Rules
Expand Down