fourstacks/nova-checkboxes

Rules not validated correctly

Closed this issue · 3 comments

I just tried to add creationRules('required') and it doesn't appear to be working. It turns the fields red if there are also other required fields but I can still submit it with nothing selected without any error.

@XGhozt - to be honest I've not really tried this field out with any validation rules yet. Will give that a whirl and see if I can track down where the issue is

@fourstacks you have not watched it?

@XGhozt You can just use a custom clusure rule which will check for a true value in the json like this :

->rules('required', 'json', function($attribute, $value, $fail) {
    if (!collect(json_decode($value, true))->containsStrict(true)) {
        return $fail('The '.$attribute.' field is invalid.');
    }
})