I have a Joi schema called directorySchema, and, among others keys, this schema has a key called parentDirectory, which type is also a directorySchema and could be null if the directory is a root/head one, and another key called directories, which type is an array of directorySchemas too. Basically this schema represents a doubly linked list.
Follow the example:
const Joi = require('@hapi/joi')
const directorySchema = Joi.object({
name: Joi.string().required(),
path: Joi.string().required(),
size: Joi.number().min(0).required(),
directories: Joi.array().items(...) // how to reference "directorySchema" here
parentDirectory: ... // and here?
})
module.exports = directorySchema
This image explains the concept of doubly linked list, the box objects represents the directories.
I would like to know, is it possible to create a double linked list to validate my objects in Joi?