I have a JSON that can have either an IBAN account number, in which case a BIC is required, or an account_number or both of them.
So, this is valid (only account_number):
"bankaccount_data": [
{
"bic": null,
"iban": null,
"account_name": "Bankgiro",
"account_number": "12345-6789",
"bank_name": "Bankgiro",
"type": "Bankgiro"
}
]
And this is valid with iban and bic:
"bankaccount_data": [
{
"bic": "BANKBIC",
"iban": "SE0123456789",
"account_name": "Bankgiro",
"account_number": null,
"bank_name": "Bankgiro",
"type": "Bankgiro"
}
]
Even this with both account_number and iban/bic:
"bankaccount_data": [
{
"bic": "BANKBIC",
"iban": "SE0123456789",
"account_name": "Bankgiro",
"account_number": "12345-6789",
"bank_name": "Bankgiro",
"type": "Bankgiro"
}
]
My problem is with requiring BOTH iban and bic if either/or exists. I have this schema which is not doing that but should "illustrate" my need:
"bankaccount_data": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"account_name": { "type": "string" },
"bank_name": { "type": [ "string", "null" ] },
"type": { "type": "string" }
},
"required": [ "type" ],
"anyOf": [
{
"type": "object",
"properties": {
"bic": { "type": "string" },
"iban": { "type": "string" }
},
"required": [ "bic", "iban" ],
"dependencies": {
"iban": [
"bic"
],
"bic": [
"iban"
]
}
},
{
"type": "object",
"properties": {
"account_number": { "type": "string" }
},
"required": [ "account_number" ]
}
]
}
]
}