owned this note
owned this note
Published
Linked with GitHub
# PE Schema syntax
## Before:
```json=
{
"presentation_definition": {
"id": "32f54163-7166-48f1-93d8-ff217bdb0653",
"input_descriptors": [
{
"id": "banking_input_1",
"name": "Bank Account Information",
"purpose": "We can only remit payment to a currently-valid bank account.",
"group": [
"A"
],
"schema": [
{
"uri": "https://bank-schemas.org/1.0.0/accounts.json"
},
{
"uri": "https://bank-schemas.org/2.0.0/accounts.json"
}
],
"constraints": {
"fields": [
{
"path": [
"$.issuer",
"$.vc.issuer",
"$.iss"
],
"purpose": "We can only verify bank accounts if they are attested by a trusted bank, auditor or regulatory authority.",
"filter": {
"type": "string",
"pattern": "did:example:123|did:example:456"
}
},
{
"path": [
"$.credentialSubject.account[*].id",
"$.vc.credentialSubject.account[*].id",
"$.account[*].id"
],
"purpose": "We can only remit payment to a currently-valid bank account in the US, France, or Germany, submitted as an ABA Acct # or IBAN.",
"filter": {
"type": "string",
"pattern": "^[0-9]{10-12}|^(DE|FR)[0-9]{2}\\s?([0-9a-zA-Z]{4}\\s?){4}[0-9a-zA-Z]{2}$"
}
},
{
"path": [
"$.credentialSubject.account[*].route",
"$.vc.credentialSubject.account[*].route",
"$.account[*].route"
],
"purpose": "We can only remit payment to a currently-valid account at a US, Japanese, or German federally-accredited bank, submitted as an ABA RTN or SWIFT code.",
"filter": {
"type": "string",
"pattern": "^[0-9]{9}|^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$"
}
}
]
}
}
]
}
}
```
## After:
```json=
{
"presentation_definition": {
"id": "32f54163-7166-48f1-93d8-ff217bdb0653",
"input_descriptors": [
{
"id": "banking_input_1",
"name": "Bank Account Information",
"purpose": "We can only remit payment to a currently-valid bank account.",
"group": [
"A"
],
"constraints": {
"fields": [
{
"path": [
"$.credentialSchema.id",
"$.vc.credentialSchema.id"
],
"purpose": "We need a credential that conforms to a bank account structure",
"filter": {
"type": "string",
"pattern": "https://bank-schemas.org/1.0.0/accounts.json|https://bank-schemas.org/2.0.0/accounts.json"
}
},
{
"path": [
"$.issuer",
"$.vc.issuer",
"$.iss"
],
"purpose": "We can only verify bank accounts if they are attested by a trusted bank, auditor or regulatory authority.",
"filter": {
"type": "string",
"pattern": "did:example:123|did:example:456"
}
},
{
"path": [
"$.credentialSubject.account[*].id",
"$.vc.credentialSubject.account[*].id",
"$.account[*].id"
],
"purpose": "We can only remit payment to a currently-valid bank account in the US, France, or Germany, submitted as an ABA Acct # or IBAN.",
"filter": {
"type": "string",
"pattern": "^[0-9]{10-12}|^(DE|FR)[0-9]{2}\\s?([0-9a-zA-Z]{4}\\s?){4}[0-9a-zA-Z]{2}$"
}
},
{
"path": [
"$.credentialSubject.account[*].route",
"$.vc.credentialSubject.account[*].route",
"$.account[*].route"
],
"purpose": "We can only remit payment to a currently-valid account at a US, Japanese, or German federally-accredited bank, submitted as an ABA RTN or SWIFT code.",
"filter": {
"type": "string",
"pattern": "^[0-9]{9}|^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$"
}
}
]
}
}
]
}
}
```
## How to constrain based on the type array:
```json=
"constraints": {
"fields": [
{
"path": [
"$.type",
"$.vc.type"
],
"purpose": "We need a credential that conforms to a bank account structure",
"filter": {
"type": "array",
"contains": {
"type": "string",
"pattern": "(BankAccountCredentailV1)|(BankAccountCredentailV2)"
}
}
}
]
}
```