{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://recit.dev/schema/v1/form-block.json",
  "x-recit-stability": "stable",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "endpoint": {
      "type": "string",
      "minLength": 1
    },
    "contract": {
      "type": "string",
      "enum": [
        "recit",
        "openapi",
        "formspree"
      ]
    },
    "submit": {
      "type": "string",
      "enum": [
        "fetch",
        "native",
        "mock"
      ]
    },
    "encoding": {
      "type": "string",
      "enum": [
        "form",
        "json"
      ]
    },
    "antispam": {
      "type": "string",
      "enum": [
        "honeypot",
        "turnstile",
        "none"
      ]
    },
    "auth": {
      "type": "string",
      "enum": [
        "none",
        "publishable-key",
        "bearer"
      ]
    },
    "publishableKey": {
      "type": "string",
      "minLength": 1
    },
    "turnstileSiteKey": {
      "type": "string",
      "minLength": 1
    },
    "privacy": {
      "type": "string",
      "minLength": 1
    },
    "retention": {
      "type": "integer",
      "minimum": 1,
      "maximum": 3650
    },
    "upload": {
      "type": "string",
      "enum": [
        "multipart",
        "presigned"
      ]
    },
    "method": {
      "type": "string",
      "const": "POST"
    },
    "openapi": {
      "type": "string",
      "minLength": 1
    },
    "operation": {
      "type": "string",
      "minLength": 1
    },
    "url": {
      "type": "string",
      "format": "uri"
    },
    "fields": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
              },
              "type": {
                "type": "string",
                "enum": [
                  "text",
                  "email",
                  "tel",
                  "url",
                  "number",
                  "range",
                  "date",
                  "time",
                  "datetime-local",
                  "textarea",
                  "select",
                  "radio",
                  "checkbox",
                  "checkbox-group",
                  "file",
                  "hidden"
                ]
              },
              "label": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                ]
              },
              "help": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                ]
              },
              "placeholder": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                ]
              },
              "required": {
                "type": "boolean"
              },
              "min": {
                "type": [
                  "number",
                  "string"
                ]
              },
              "max": {
                "type": [
                  "number",
                  "string"
                ]
              },
              "minlength": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "maxlength": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "pattern": {
                "type": "string",
                "minLength": 1
              },
              "step": {
                "anyOf": [
                  {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  {
                    "type": "string",
                    "const": "any"
                  }
                ]
              },
              "autocomplete": {
                "type": "string",
                "minLength": 1
              },
              "rows": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "accept": {
                "type": "string",
                "minLength": 1
              },
              "maxSize": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "value": {
                "type": "string"
              },
              "options": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "value": {
                      "type": "string",
                      "minLength": 1
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    }
                  },
                  "required": [
                    "value",
                    "label"
                  ],
                  "additionalProperties": false
                }
              },
              "other": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                ]
              },
              "visibleIf": {
                "type": "string",
                "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
              },
              "requiredIf": {
                "type": "string",
                "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
              },
              "enabledIf": {
                "type": "string",
                "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
              },
              "compute": {
                "type": "string",
                "minLength": 1
              },
              "outside": {
                "type": "boolean"
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "legend": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                ]
              },
              "fields": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "text",
                        "email",
                        "tel",
                        "url",
                        "number",
                        "range",
                        "date",
                        "time",
                        "datetime-local",
                        "textarea",
                        "select",
                        "radio",
                        "checkbox",
                        "checkbox-group",
                        "file",
                        "hidden"
                      ]
                    },
                    "label": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "help": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "placeholder": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "required": {
                      "type": "boolean"
                    },
                    "min": {
                      "type": [
                        "number",
                        "string"
                      ]
                    },
                    "max": {
                      "type": [
                        "number",
                        "string"
                      ]
                    },
                    "minlength": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "maxlength": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    },
                    "pattern": {
                      "type": "string",
                      "minLength": 1
                    },
                    "step": {
                      "anyOf": [
                        {
                          "type": "number",
                          "exclusiveMinimum": 0
                        },
                        {
                          "type": "string",
                          "const": "any"
                        }
                      ]
                    },
                    "autocomplete": {
                      "type": "string",
                      "minLength": 1
                    },
                    "rows": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    },
                    "accept": {
                      "type": "string",
                      "minLength": 1
                    },
                    "maxSize": {
                      "type": "integer",
                      "exclusiveMinimum": 0,
                      "maximum": 9007199254740991
                    },
                    "value": {
                      "type": "string"
                    },
                    "options": {
                      "minItems": 1,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "value": {
                            "type": "string",
                            "minLength": 1
                          },
                          "label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "string"
                                }
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "string"
                                }
                              }
                            ]
                          }
                        },
                        "required": [
                          "value",
                          "label"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "other": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      ]
                    },
                    "visibleIf": {
                      "type": "string",
                      "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
                    },
                    "requiredIf": {
                      "type": "string",
                      "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
                    },
                    "enabledIf": {
                      "type": "string",
                      "pattern": "^(!?[A-Za-z][A-Za-z0-9_.-]*|[A-Za-z][A-Za-z0-9_.-]*!?=[^=]*)$"
                    },
                    "compute": {
                      "type": "string",
                      "minLength": 1
                    },
                    "outside": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "name"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "legend",
              "fields"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "consent": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_.-]*$"
        },
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          ]
        },
        "required": {
          "type": "boolean"
        },
        "version": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "name",
        "label",
        "version"
      ],
      "additionalProperties": false
    },
    "submitLabel": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      ]
    },
    "success": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      ]
    }
  },
  "required": [
    "id",
    "fields"
  ],
  "additionalProperties": false
}
