শর্তসাপেক্ষ Schema (oneOf)
উন্নত JSON Schema
পলিমরফিক পেমেন্ট পদ্ধতি যাচাইকরণের জন্য oneOf বিচ্ছিন্নকারী ব্যবহারকারী একটি JSON Schema। আপনার প্রজেক্ট বা পরীক্ষার জন্য একটি বাস্তবসম্মত উদাহরণ।
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "PaymentMethod",
"type": "object",
"discriminator": { "propertyName": "type" },
"oneOf": [
{
"type": "object",
"properties": {
"type": { "const": "credit_card" },
"cardNumber": { "type": "string", "pattern": "^[0-9]{16}$" },
"expMonth": { "type": "integer", "minimum": 1, "maximum": 12 },
"expYear": { "type": "integer", "minimum": 2024 }
},
"required": ["type", "cardNumber", "expMonth", "expYear"]
},
{
"type": "object",
"properties": {
"type": { "const": "paypal" },
"email": { "type": "string", "format": "email" }
},
"required": ["type", "email"]
},
{
"type": "object",
"properties": {
"type": { "const": "bank_transfer" },
"iban": { "type": "string" },
"bic": { "type": "string" }
},
"required": ["type", "iban"]
}
]
} টুলে খুলুন
সম্পর্কিত টুল
আরও উদাহরণ
- schema
- conditional
- if-then-else
- advanced