-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for embedded objects #372
Comments
Can you provide an example of your resource config and what object you want to store ? |
Can you please provide a example of your schema @BryanHunt? We're still using an older version of Joi to support Node.js v6, but I've been working on moving to v8 + transpilling to support v6, which would allow use to use the latest version of Joi which will probably support your use case. Anyway, if you can provide an example I can have a more detailed look at this. |
Here's a specific use-case I'm about to have: {
"id" : "94419dc7-a945-4dd3-8f01-c778ef49a5ac",
"type" : "notifications",
"attributes" : {
"sentOn" : 1518932462583.0,
"tags" : [
{ "key1" : "value1" },
{ "key2" : "value2" }
]
}
} In this specific use-case, a notification contains an array of tags that are key:value pairs where the keys and values are arbitrary (user defined). The keys are restricted to strings, but the values could be strings, numbers, etc. Here is another example use-case: {
"id" : "94419dc7-a945-4dd3-8f01-c778ef49a5ac",
"type" : "widgets",
"attributes" : {
"name" : "My Widget",
"backgroundColor" : {
"r" : 109,
"g" : 25,
"b" : 193
}
}
} |
Thanks for providing the example. I'm planning on spending some time next week on the project so I should be able to look into updating Joi and see if we can support your use case. |
We would also like to validate nested objects but this isn't possible at the moment? |
You can validate via Joi |
Mistakenly used .valid() instead of .items() for validating objects within an array. It's working now 👍 |
We have a use-case where we need to use embedded objects. According to the JSON-API spec:
When we try to create a schema containing an embedded object, we get:
The text was updated successfully, but these errors were encountered: