public function validator($type, $validator)
    {
        $this->validators[$type] = $validator;

        $this->resolver($type, function ($data, $resourceId) use ($type) {
            /** @var \Drp\JsonApiParser\Contracts\ValidatorExecutor[] $validators */
            $validators = Arr::wrap($this->validators[$type]);

            foreach ($validators as $validator) {
                $data['id'] = $resourceId;
                $validator->with($data);

                $result = $validator->passes();

                if (!$result) {
                    $errors = $validator->errors();

                    $types = explode('.', $type);
                    $key = end($types);

                    if ($resourceId !== null) {
                        $key .= '_' . $resourceId;
                    }

                    $this->errors[$key] = array_merge(Arr::get($this->errors, $key, []), $errors);
                }
            }
        });

        return $this;
    }