JSON Schema 2020-12
Сравнение предложений подрядчиков
Псевдонимные предложения с валютой, суммой и scope score.
Схема
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://sharprod.com/schemas/vendor-bid-comparison.schema.json",
"title": "SHAR Production Vendor Bid Comparison Contract",
"type": "object",
"additionalProperties": false,
"properties": {
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"bids": {
"type": "array",
"minItems": 2,
"items": {
"type": "object",
"required": [
"vendor_ref",
"total",
"scope_score"
],
"properties": {
"vendor_ref": {
"type": "string",
"pattern": "^vendor-[a-z0-9-]+$"
},
"total": {
"type": "number",
"minimum": 0
},
"scope_score": {
"type": "integer",
"minimum": 0,
"maximum": 100
}
}
}
}
},
"required": [
"currency",
"bids"
]
}Проверенный пример
{
"input": {
"currency": "RUB",
"bids": [
{
"vendor_ref": "vendor-alpha",
"total": 100000,
"scope_score": 82
},
{
"vendor_ref": "vendor-beta",
"total": 120000,
"scope_score": 91
}
]
},
"result": {
"valid": true,
"errors": []
}
}Отклонённый пример
{
"input": {
"currency": "rub",
"bids": [
{
"vendor_ref": "Real Company",
"total": -1,
"scope_score": 101
}
]
},
"result": {
"valid": false,
"errors": [
{
"instancePath": "/currency",
"schemaPath": "#/properties/currency/pattern",
"keyword": "pattern",
"params": {
"pattern": "^[A-Z]{3}$"
},
"message": "must match pattern \"^[A-Z]{3}$\""
}
]
}
}