Taglist Validation

Forms\Components\TagsInput::make('tags')->separator(',')->suggestions($tagset)->rules([
function () {
return function (string $tagset, $value, Closure $fail) {
foreach ($value as $tag) {
if(str_contains($tagset, $tag)) {
$fail('Check that all tags are valid.');
}
}
};
},
]),
Forms\Components\TagsInput::make('tags')->separator(',')->suggestions($tagset)->rules([
function () {
return function (string $tagset, $value, Closure $fail) {
foreach ($value as $tag) {
if(str_contains($tagset, $tag)) {
$fail('Check that all tags are valid.');
}
}
};
},
]),
$tagset = [
'fire',
'water',
'mold',
];
$tagset = [
'fire',
'water',
'mold',
];
I am trying to validate from an array of strings against the input in the tags field. However, it validates from all strings, no matter if they're in the tagset currently. What am I missing? Maybe I just need a fresh pair of eyes to help me out here.
0 Replies
No replies yetBe the first to reply to this messageJoin