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

> Checks if the data is valid according to 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>;
};

Checks whether the incoming data matches a JSON schema you provide. A JSON schema is a set of rules that describes what valid data looks like, such as which fields must be present, what type each one should be, and which values are allowed. Use this to confirm a record has the shape another system expects before you send it on, or to separate well-formed records from ones that are missing fields or hold the wrong kind of value. You supply the schema in the Schema field, and the condition answers yes when the data satisfies every rule in it.

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

## Fields

<FormField property="schema" label="Schema">
  The JSON schema the incoming data is checked against. You write the rules here, for example requiring certain fields or fixing the type of a value. The condition passes only when the data satisfies every rule in the schema.
</FormField>

<FormField property="enableLogging" label="Log failed validation results">
  When turned on, records that fail the check are written to the log together with the reason they did not match, which helps you see what was wrong. Leave it off to keep logs quiet and simply route failing records elsewhere.
</FormField>

## Sample data

The condition was run with a small schema that requires the value to be a whole number, applied to a `qty` field.

| Field  | Value                   |
| ------ | ----------------------- |
| Schema | `{ "type": "integer" }` |

| Incoming value   | Result         |
| ---------------- | -------------- |
| `3`              | Matches        |
| `"three"` (text) | Does not match |

```json Configuration theme={null}
{
  "prototype": "json-schema-validator",
  "parameters": {
    "schema": { "type": "integer" }
  }
}
```
