From 6df51b947b2f1d2c706b4605e7933206d3bdf616 Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Wed, 27 Mar 2024 19:18:20 -0400 Subject: [PATCH] Update string based rule examples. --- content/collections/docs/validation.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/content/collections/docs/validation.md b/content/collections/docs/validation.md index 63648f777..a1f1924ad 100644 --- a/content/collections/docs/validation.md +++ b/content/collections/docs/validation.md @@ -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. @@ -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 @@ -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