@salesforce/core
    Preparing search index...

    Class SchemaValidator

    Loads a JSON schema and performs validations against JSON objects.

    For sfdx-project.json and scratch org definitions, use the exported zod schemas (ProjectJsonSchema, ScratchOrgDefSchema) from '@salesforce/core'. For custom schemas, use a schema validator library like zod directly.

    Index
    • Creates a new SchemaValidator instance given a logger and path to a schema file.

      Parameters

      • logger: Logger

        An Logger instance on which to base this class's logger.

      • schemaPath: string

        The path to the schema file to load and use for validation.

      Returns SchemaValidator

    • Loads a JSON schema from the schemaPath parameter provided at instantiation.

      Returns Promise<JsonMap>

      For sfdx-project.json and scratch org definitions, use the exported zod schemas (ProjectJsonSchema, ScratchOrgDefSchema) from '@salesforce/core'. For custom schemas, use a schema validator library like zod directly.

    • Loads a JSON schema from the schemaPath parameter provided at instantiation.

      Returns JsonMap

      For sfdx-project.json and scratch org definitions, use the exported zod schemas (ProjectJsonSchema, ScratchOrgDefSchema) from '@salesforce/core'. For custom schemas, use a schema validator library like zod directly.

    • Performs validation of JSON data against the schema located at the schemaPath value provided at instantiation.

      Throws SfError{ name: 'ValidationSchemaFieldError' } If there are known validations errors. Throws SfError{ name: 'ValidationSchemaUnknownError' } If there are unknown validations errors.

      Parameters

      • json: AnyJson

        A JSON value to validate against this instance's target schema.

      Returns Promise<AnyJson>

      The validated JSON data.

      For sfdx-project.json and scratch org definitions, use the exported zod schemas (ProjectJsonSchema, ScratchOrgDefSchema) from '@salesforce/core'. For custom schemas, use a schema validator library like zod directly.

    • Performs validation of JSON data against the schema located at the schemaPath value provided at instantiation.

      Throws SfError{ name: 'ValidationSchemaFieldError' } If there are known validations errors. Throws SfError{ name: 'ValidationSchemaUnknownError' } If there are unknown validations errors.

      Type Parameters

      • T extends AnyJson

      Parameters

      • json: T

        A JSON value to validate against this instance's target schema.

      Returns T

      The validated JSON data.

      For sfdx-project.json and scratch org definitions, use the exported zod schemas (ProjectJsonSchema, ScratchOrgDefSchema) from '@salesforce/core'. For custom schemas, use a schema validator library like zod directly.