nestedRecursiveRules

How can I add custom messages to nestedRecursiveRules() in a tag input? In the example below, I get the following error: "The mountedActionsData.0.tags.7 field must not be greater than 25 characters."
TagsInput::make('tags')
->rules(['max:10'])
->validationMessages([
'max' => 'You can only add up to :max tags.',
])
->nestedRecursiveRules([
'min:3',
'max:25',
]);
TagsInput::make('tags')
->rules(['max:10'])
->validationMessages([
'max' => 'You can only add up to :max tags.',
])
->nestedRecursiveRules([
'min:3',
'max:25',
]);
Solution:
i am suggesting ```php ->validationMessages([ 'max' => 'You can only add up to :max tags.',...
Jump to solution
6 Replies
Dan Harrin
Dan Harrin2mo ago
have you potentially tried '*.max' as the key
BuddhaNature
BuddhaNature2mo ago
This part of what I posted works:
->validationMessages([
'max' => 'You can only add up to :max tags.',
])
->validationMessages([
'max' => 'You can only add up to :max tags.',
])
That limits the total number of tags to five and generates a usefull message to the user. Which is great. However, I want to limit each individual tag to 3 to 25 characters. The validation itself works fine, but I don't know how to change the validation message for the nested rules. Also, *.max won't be ideal because max works differently in the content of the number of tags and the total length of individual tags.
Dan Harrin
Dan Harrin2mo ago
i know
Solution
Dan Harrin
Dan Harrin2mo ago
i am suggesting
->validationMessages([
'max' => 'You can only add up to :max tags.',
'*.max' => 'Test :max message',
])
->validationMessages([
'max' => 'You can only add up to :max tags.',
'*.max' => 'Test :max message',
])
Dan Harrin
Dan Harrin2mo ago
idk if it will work but it might be worth a shot
BuddhaNature
BuddhaNature2mo ago
Yes. That worked. Thank you.