{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "ItemType",
    "description": "JSON schema for item_type.",
    "additionalProperties": false,
    "propertiesOrder": [
        "name",
        "description",
        "type"
    ],
    "required": [
        "$schema",
        "pid",
        "name",
        "organisation",
        "type"
    ],
    "properties": {
        "$schema": {
            "title": "Schema",
            "description": "Schema to validate item_type records against.",
            "type": "string",
            "minLength": 9,
            "default": "https://ils.rero.ch/schemas/item_types/item_type-v0.0.1.json"
        },
        "pid": {
            "title": "ItemType ID.",
            "type": "string",
            "minLength": 1
        },
        "name": {
            "title": "Name",
            "description": "Name of the ItemType.",
            "type": "string",
            "minLength": 1,
            "form": {
                "focus": true,
                "validation": {
                    "validators": {
                        "valueAlreadyExists": {
                            "term": "item_type_name"
                        }
                    },
                    "messages": {
                        "alreadyTakenMessage": "The item type name is already taken."
                    }
                }
            }
        },
        "description": {
            "title": "Description",
            "description": "Description of the ItemType.",
            "type": "string",
            "minLength": 1
        },
        "type": {
            "title": "Type",
            "description": "Type of the circulation category.",
            "type": "string",
            "default": "standard",
            "enum": [
                "online",
                "standard"
            ],
            "form": {
                "options": [
                    {
                        "value": "standard",
                        "label": "Standard"
                    },
                    {
                        "value": "online",
                        "label": "Online"
                    }
                ],
                "validation": {
                    "validators": {
                        "valueAlreadyExists": {
                            "remoteRecordType": "item_types",
                            "limitToValues": [
                                "online"
                            ]
                        }
                    },
                    "messages": {
                        "alreadyTakenMessage": "Another online item type exists in this organisation."
                    }
                }
            }
        },
        "organisation": {
            "title": "Organisation",
            "type": "object",
            "properties": {
                "$ref": {
                    "title": "Organisation URI",
                    "type": "string"
                }
            }
        }
    }
}