This is a draft API. We appreciate your feedback and ideas in
It may happen that you updated your profiles when data is already in your database or you want to do efficiently load a batch of data and validate it later. API consists of 3 procedures and a couple of resources:
- run validation
- inspect results (useful for async mode)
- clear validation results
Prepare data
To illustrate let's create some invalid data in Aidbox:
POST /Patient
content-type: text/yaml
id: 'pt1'
birthDate: '1980-03-05'
Break data from DB Console:
update patient
set resource = resource || '{"ups": "extra"}'
where id = 'pt1'
returning *
aidbox.validation/batch-validation
You can validate your existing data with our new rpc aidbox.validation/batch-validation:
POST /rpc
content-type: text/yaml
method: aidbox.validation/batch-validation
params:
# resourceType to validate
resource: Patient
id: pt-validation-run-1
# you can limit number of resources to validate
limit: 100
# you can stop process on specific number of invalid resources
errorsThreshold: 10
# where section of resources query
filter: "resource#>>'{birthDate}' is not null"
## run validation asynchronously
# async: true
## specify profiles to validate
# profiles: ['profile-url-1', 'profile-url-2']
## specify zen schemas to validation
#schemas: ['myapp/Patient', 'us-core.patient/Patient']
# response
result:
id: pt-validation-run-2
valid: 0
invalid: 1
duration: 15
problems:
- resource:
id: pt1
ups: extra
meta:
createdAt: '2021-08-05T16:36:37.723008+03:00'
versionId: '1224'
lastUpdated: '2021-08-05T16:36:37.723008+03:00'
birthDate: '1980-03-05'
resourceType: Patient
errors:
- path:
- ups
message: extra property
aidbox.validation/batch-validation-result
If you run validation in async mode, it will respond instantly and run validation in the background. You can get validation results with RPC aidbox.validation/batch-validation-result
When you run validation operation aidbox internally creates resource BatchValidationRun and put errors of validation in BatchValidationError. You can access these resources through standard CRUD/Search API