I'm using AJV Schema validator on NodeJS and wish to add userID
from sessionObject
to every incoming payload so that I can store userID
for each transaction.
I wish to know if that can be done in json schemas.
sample Incoming Client payload -
Client: {
Client_Id: 12,
ClientName: 'jon',
Address: [{
Address_Id: 22,
Street: 'Sesimi Street',
City: 'Mumbai'
}
],
Contact: [{
Contact_Id: 23,
Phone: 11111111,
Email: "jon@doe.com"}]
Desired object post schema Validation -
Client: {
Client_Id: 12,
ClientName: 'jon',
UserId: 12121,
Address: [{
Address_Id: 22,
Street: 'Sesimi Street',
City: 'Mumbai',
UserId: 12121
}
],
Contact: [{
Contact_Id: 23,
Phone: 11111111,
Email: "jon@doe.com",
UserId: 12121
}]
Since incoming payloads are huge, I believe it would be best to do assignments at schema validation point instead of doing recursive operations inside of my application. I'm open to suggestions. Thank you