> ## 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.

# Validates against JSON schema

> Filters items by validating against the supplied JSON 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>;
};

Keeps an item only when it passes a JSON schema check. A JSON schema is a description of the shape your data should have: which fields are required, what type each one should be, and what values are allowed. Use this to let through only the well-formed records, for example products that have a text SKU and a numeric price, while filtering out the ones that don't. You can validate the whole item or just one part of it.

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

## Fields

<FormField property="schema" label="Schema">
  The JSON schema the item is checked against. Describe the shape an item must have, for example which fields are required and what type each one should be. An item is kept when it matches this schema.
</FormField>

<FormField property="enableLogging" label="Log failed validation results">
  When on, items that fail validation are written to the log so you can see why they were filtered out. Off by default.
</FormField>

<FormField property="pattern" label="Pattern to data to validate">
  Limits the check to one part of the item instead of the whole record. Give the path to the data you want validated. Leave it empty to validate the entire item.
</FormField>

## Sample data

This filter answers yes or no for each item, so there is no before and after. The example uses a schema that requires a text `sku` and a numeric `price`.

| Field  | Value                                      |
| ------ | ------------------------------------------ |
| Schema | requires `sku` (text) and `price` (number) |

| Incoming item                        | Result         |
| ------------------------------------ | -------------- |
| `{ "sku": "A-100", "price": 19.99 }` | matches        |
| `{ "sku": "B-200" }`                 | does not match |

The first item is kept because it has both a text SKU and a numeric price. The second is filtered out because it is missing `price`.

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