1// Copyright (C) 2018 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3
4{
5    "$id": "http://unicode.org/icu-filter-schema",
6    "$schema": "http://json-schema.org/draft-04/schema#",
7    "description": "JSON Schema for an ICU data filter file",
8    "type": "object",
9    "properties": {
10        "strategy": {
11            "type": "string",
12            "enum": ["additive", "subtractive"]
13        },
14        "localeFilter": { "$ref": "#/definitions/filter" },
15        "featureFilters": {
16            "type": "object",
17            "additionalProperties": {
18                "oneOf": [
19                    { "$ref": "#/definitions/filter" },
20                    {
21                        "type": "string",
22                        "enum": ["include", "exclude"]
23                    }
24                ]
25            }
26        },
27        "resourceFilters": {
28            "type": "array",
29            "items": {
30                "type": "object",
31                "properties": {
32                    "categories": {
33                        "type": "array",
34                        "items": { "type": "string" }
35                    },
36                    "files": { "$ref": "#/definitions/filter" },
37                    "rules": {
38                        "type": "array",
39                        "items": {
40                            "type": "string",
41                            "pattern": "^[+-]/[\\S]*$"
42                        }
43                    }
44                },
45                "required": ["categories", "rules"],
46                "additionalProperties": false
47            }
48        },
49        "fileReplacements": {
50            "type": "object",
51            "properties": {
52                "directory": {
53                    "type": "string",
54                    "pattern": "^(\\$SRC|\\$FILTERS|\\$CWD|/$|/[^/]+)(/[^/]+)*$"
55                },
56                "replacements": {
57                    "type": "array",
58                    "items": {
59                        "oneOf": [
60                            { "type": "string" },
61                            {
62                                "type": "object",
63                                "properties": {
64                                    "src": { "type": "string" },
65                                    "dest": { "type": "string" }
66                                },
67                                "additionalProperties": false,
68                                "required": ["src", "dest"]
69                            }
70                        ]
71                    }
72                }
73            },
74            "additionalProperties": false,
75            "required": ["directory", "replacements"]
76        },
77        "collationUCAData": {
78            "type": "string",
79            "enum": ["unihan", "implicithan"]
80        },
81        "usePoolBundle": {
82            "type": "boolean"
83        }
84    },
85    "additionalProperties": false,
86    "definitions": {
87        "filter": {
88            "type": "object",
89            "oneOf": [
90                {
91                    "properties": {
92                        "filterType": {
93                            "$ref": "#/definitions/blacklistWhitelistFilterTypes"
94                        },
95                        "whitelist": { "$ref": "#/definitions/stringList" }
96                    },
97                    "required": ["whitelist"],
98                    "additionalProperties": false
99                },
100                {
101                    "properties": {
102                        "filterType": {
103                            "$ref": "#/definitions/blacklistWhitelistFilterTypes"
104                        },
105                        "blacklist": { "$ref": "#/definitions/stringList" }
106                    },
107                    "required": ["blacklist"],
108                    "additionalProperties": false
109                },
110                {
111                    "properties": {
112                        "filterType": {
113                            "type": "string",
114                            "enum": ["exclude"]
115                        }
116                    },
117                    "required": ["filterType"],
118                    "additionalProperties": false
119                },
120                {
121                    "properties": {
122                        "filterType": {
123                            "type": "string",
124                            "enum": ["locale"]
125                        },
126                        "includeChildren": {
127                            "type": "boolean"
128                        },
129                        "includeScripts": {
130                            "type": "boolean"
131                        },
132                        "whitelist": { "$ref": "#/definitions/stringList" }
133                    },
134                    "required": ["filterType", "whitelist"],
135                    "additionalProperties": false
136                },
137                {
138                    "properties": {
139                        "filterType": {
140                            "type": "string",
141                            "enum": ["union"]
142                        },
143                        "unionOf": {
144                            "type": "array",
145                            "items": { "$ref": "#/definitions/filter" }
146                        }
147                    },
148                    "required": ["filterType", "unionOf"],
149                    "additionalProperties": false
150                }
151            ]
152        },
153        "blacklistWhitelistFilterTypes": {
154            "type": "string",
155            "enum": [
156                "language",
157                "regex"
158            ]
159        },
160        "stringList": {
161            "type": "array",
162            "items": {
163                "type": "string"
164            },
165            "minItems": 1,
166            "uniqueItems": true
167        }
168    }
169}
170