{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Form meta schema",
    "description": "Schema used for data type validation.",
    "type": "array",
    "minItems": 1,
    "_uniqueItems": true,
    "items": {
        "oneOf": [
            {
                "$ref": "#/types/string"
            },
            {
                "$ref": "#/types/boolean"
            },
            {
                "$ref": "#/types/integer"
            },
            {
                "$ref": "#/types/decimal"
            },
            {
                "$ref": "#/types/date"
            },
            {
                "$ref": "#/types/datetime"
            },
            {
                "$ref": "#/types/secret"
            },
            {
                "$ref": "#/types/file"
            },
            {
                "$ref": "#/types/dir"
            },
            {
                "$ref": "#/types/url"
            },
            {
                "$ref": "#/types/json"
            },
            {
                "$ref": "#/types/list_string"
            },
            {
                "$ref": "#/types/list_integer"
            },
            {
                "$ref": "#/types/list_decimal"
            },
            {
                "$ref": "#/types/list_file"
            },
            {
                "$ref": "#/types/list_dir"
            },
            {
                "$ref": "#/types/list_url"
            }
        ]
    },
    "types": {
        "string": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:(string|text):$"
                },
                "value": {
                    "type": "string"
                }
            }
        },
        "boolean": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:boolean:$"
                },
                "value": {
                    "type": "boolean"
                }
            }
        },
        "integer": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^(basic:integer|data(:[a-z0-9:]+)?):$"
                },
                "value": {
                    "type": "integer"
                }
            }
        },
        "decimal": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:decimal:$"
                },
                "value": {
                    "type": "number"
                }
            }
        },
        "date": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:date:$"
                },
                "value": {
                    "type": "string",
                    "pattern": "^(19|20)\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$"
                }
            }
        },
        "datetime": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:datetime:$"
                },
                "value": {
                    "type": "string",
                    "pattern": "^(19|20)\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) (?:(?:([01]?\\d|2[0-3]):)?([0-5]?\\d):)?([0-5]?\\d)$"
                }
            }
        },
        "secret": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:secret:$"
                },
                "value": {
                    "type": "object",
                    "required": [
                        "handle"
                    ],
                    "additionalProperties": false,
                    "properties": {
                        "handle": {
                            "type": "string",
                            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                        }
                    }
                }
            }
        },
        "file": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:file:(html:)?$"
                },
                "value": {
                    "type": "object",
                    "required": [
                        "file"
                    ],
                    "additionalProperties": false,
                    "properties": {
                        "file": {
                            "type": "string"
                        },
                        "size": {
                            "type": "number"
                        },
                        "total_size": {
                            "type": "number"
                        },
                        "is_remote": {
                            "type": "boolean"
                        },
                        "file_temp": {
                            "type": "string"
                        },
                        "refs": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "dir": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:dir:$"
                },
                "value": {
                    "type": "object",
                    "required": [
                        "dir"
                    ],
                    "additionalProperties": false,
                    "properties": {
                        "dir": {
                            "type": "string"
                        },
                        "size": {
                            "type": "number"
                        },
                        "total_size": {
                            "type": "number"
                        },
                        "refs": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "url": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:(url:download|url:view|url:link):$"
                },
                "value": {
                    "type": "object",
                    "required": [
                        "url"
                    ],
                    "additionalProperties": false,
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "url": {
                            "type": "string"
                        },
                        "refs": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "json": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^basic:json:$"
                },
                "value": {
                    "type": "number"
                }
            }
        },
        "list_string": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^list:basic:(string|text):$"
                },
                "value": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "_uniqueItems": false
                }
            }
        },
        "list_integer": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^list:(basic:integer|data(:[a-z0-9:]+)?):$"
                },
                "value": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    },
                    "_uniqueItems": false
                }
            }
        },
        "list_decimal": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^list:basic:decimal:$"
                },
                "value": {
                    "type": "array",
                    "items": {
                        "type": "number"
                    },
                    "_uniqueItems": false
                }
            }
        },
        "list_file": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^list:basic:file:(html:)?$"
                },
                "value": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "required": [
                            "file"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "file": {
                                "type": "string"
                            },
                            "size": {
                                "type": "number"
                            },
                            "total_size": {
                                "type": "number"
                            },
                            "is_remote": {
                                "type": "boolean"
                            },
                            "file_temp": {
                                "type": "string"
                            },
                            "refs": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "_uniqueItems": false
                }
            }
        },
        "list_dir": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^list:basic:dir:$"
                },
                "value": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "required": [
                            "dir"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "dir": {
                                "type": "string"
                            },
                            "size": {
                                "type": "number"
                            },
                            "total_size": {
                                "type": "number"
                            },
                            "refs": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "_uniqueItems": false
                }
            }
        },
        "list_url": {
            "type": "object",
            "required": [
                "type",
                "value"
            ],
            "additionalProperties": false,
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^list:basic:(url:download|url:view|url:link):$"
                },
                "value": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "required": [
                            "url"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "url": {
                                "type": "string"
                            },
                            "refs": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "_uniqueItems": false
                }
            }
        }
    }
}