{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "PatronType",
    "description": "JSON schema for patron_types.",
    "additionalProperties": false,
    "propertiesOrder": [
        "name",
        "description",
        "subscription_amount"
    ],
    "required": [
        "$schema",
        "pid",
        "name",
        "organisation"
    ],
    "properties": {
        "$schema": {
            "title": "Schema",
            "description": "Schema to validate patron_types records against.",
            "type": "string",
            "minLength": 9,
            "default": "https://ils.rero.ch/schemas/patron_types/patron_type-v0.0.1.json"
        },
        "pid": {
            "title": "Patron type ID",
            "type": "string",
            "minLength": 1
        },
        "name": {
            "title": "Name",
            "description": "The name of the patron type",
            "type": "string",
            "minLength": 2,
            "form": {
                "focus": true,
                "validation": {
                    "validators": {
                        "valueAlreadyExists": {
                            "term": "patron_type_name"
                        }
                    },
                    "messages": {
                        "alreadyTakenMessage": "The patron type name is already taken."
                    }
                }
            }
        },
        "description": {
            "title": "Description",
            "description": "The description of the patron type.",
            "type": "string"
        },
        "organisation": {
            "title": "Organisation",
            "type": "object",
            "properties": {
                "$ref": {
                    "title": "Organisation URI",
                    "type": "string",
                    "pattern": "^https://ils.rero.ch/api/organisations/.*?$"
                }
            }
        },
        "subscription_amount": {
            "title": "Amount",
            "description": "Yearly amount due by patrons linked to this patron type.",
            "type": "number",
            "default": 0,
            "minimum": 0,
            "form": {
                "wrappers": [
                    "toggle-switch",
                    "form-field"
                ],
                "templateOptions": {
                    "toggle-switch": {
                        "label": "Yearly subscription",
                        "description": "Activation of subscription fees for patrons linked to this type."
                    }
                }
            }
        }
    }
}