This document shows you how to validate schemas for Pub/Sub topics.
The validation check does not check the compatibility of the new revision
with the older revisions.

## Before you begin

- Understand how [Pub/Sub schemas work](https://docs.cloud.google.com/pubsub/docs/schemas.md.txt).
- [Create a schema](https://docs.cloud.google.com/pubsub/docs/create-schemas.md.txt).

### Required roles and permissions


To get the permissions that
you need to validate schemas definitions and manage them,

ask your administrator to grant you the
[Pub/Sub Editor](https://docs.cloud.google.com/iam/docs/roles-permissions/pubsub.md.txt#pubsub.editor) (`roles/pubsub.editor`) IAM role on your project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


This predefined role contains

the permissions required to validate schemas definitions and manage them. To see the exact permissions that are
required, expand the **Required permissions** section:


#### Required permissions

The following permissions are required to validate schemas definitions and manage them:

- Create schema: `pubsub.schemas.create`
- Attach schema to topic: `pubsub.schemas.attach`
- Commit a schema revision: `pubsub.schemas.commit`
- Delete a schema or a schema revision: `pubsub.schemas.delete`
- Get a schema or schema revisions: `pubsub.schemas.get`
- List schemas: `pubsub.schemas.list`
- List schema revisions: `pubsub.schemas.listRevisions`
- Rollback a schema: `pubsub.schemas.rollback`
- Validate a message: `pubsub.schemas.validate`
- Get the IAM policy for a schema: `pubsub.schemas.getIamPolicy`
- Configure the [IAM policy](https://docs.cloud.google.com/iam/docs/reference/rest/v1/Policy.md.txt) for a schema: `pubsub.schemas.setIamPolicy`


You might also be able to get
these permissions
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

You can grant roles and permissions to principals such as users, groups,
domains, or service accounts. You can create a schema in one project and
attach it to a topic located in a different project.
Ensure that you have the required permissions for
each project.

## Validate a schema definition

You can validate a schema by using the
Google Cloud console, the gcloud CLI, the Pub/Sub API,
or the Cloud Client Libraries.

Follow the steps discussed in [Create a schema](https://docs.cloud.google.com/pubsub/docs/create-schemas.md.txt).

The validation check does not check the compatibility of the new revision
with the older revisions.

## What's next

- [Validate a message for a schema](https://docs.cloud.google.com/pubsub/docs/validate-schema-message.md.txt)

- [Publish messages to a topic with a schema](https://docs.cloud.google.com/pubsub/docs/publish-topics-schema.md.txt)