1 week ago

At least one value selected with validations

Posted 1 week ago by AhmedNaser

Hi there I have an array of Boolean values I want to make sure that the array has at least 1 true value

  public function rules()
        return [
            'name'                     => ['required', 'string', 'min:2', 'max:100', 'unique:roles,name'],
            'permissions'              => ['required', 'array'],
            'permissions.*'            => ['required', 'array'],
            'permissions.*.*'          => ['required', 'array'],
            'permissions.*.*.name'     => ['required', 'alpha_dash'],
            'permissions.*.*.selected' => ['required', 'boolean'],

Please sign in or create an account to participate in this conversation.