> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate by JSON schema

> Validates JSON data based on the supplied schema.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Checks each item against a JSON schema and drops the ones that do not match. A JSON schema describes the shape your data should have, such as which fields are required, what type each value must be, and which values are allowed. Items that satisfy the schema pass through unchanged; items that fail are filtered out of the list. Use this to keep only well-formed records and stop incomplete or malformed data from reaching the next step.

This documentation describes: [Schema](/schemas/transformer-step/json-schema-validator-filter)

## Fields

<FormField property="useSchema" label="Schema to use">
  Where the schema comes from. Choose **Use schema from entity** (the default) to validate against a schema that travels with the item itself, or **Use custom schema** to type the schema in the next field. The allowed values are `fromEntity` and `custom`.
</FormField>

<FormField property="schema" label="Schema">
  The JSON schema to validate against. This field appears and is required only when **Schema to use** is set to **Use custom schema**. Enter the schema as JSON, describing the required fields, value types, and allowed values your items must match.
</FormField>

<FormField property="pattern" label="Pattern to data to validate">
  A dot-notated pattern pointing at the part of each item you want to validate, for example `address` to check only the address block. Leave it empty to validate the whole item.
</FormField>

<FormField property="enableLogging" label="Log failed validation results">
  When turned on, every item that fails validation is written to the logs, with the reason it failed. Useful while you are setting up the schema and want to see exactly why items are being dropped. Off by default.
</FormField>

## Sample data

This transformer does not change the items that pass; it only removes the ones that fail the schema. The values you set decide what counts as valid.

For example, with a custom schema that requires a `sku` (text) and a `price` (number):

| Field         | Value                                        |
| ------------- | -------------------------------------------- |
| Schema to use | Use custom schema                            |
| Schema        | requires `sku` (string) and `price` (number) |
| Pattern       | empty (whole item)                           |

| Item                               | Result                            |
| ---------------------------------- | --------------------------------- |
| `{ "sku": "A1", "price": 19.99 }`  | Passes (matches the schema)       |
| `{ "sku": "A1" }`                  | Dropped (`price` is missing)      |
| `{ "sku": "A1", "price": "free" }` | Dropped (`price` is not a number) |

```json Configuration theme={null}
{
  "prototype": "json-schema-validator-filter",
  "parameters": {
    "useSchema": "custom",
    "schema": {
      "type": "object",
      "required": ["sku", "price"],
      "properties": {
        "sku": { "type": "string" },
        "price": { "type": "number" }
      }
    },
    "enableLogging": false
  }
}
```
