/joi-traverse

External traversal lib for joi that prevents break-on-update

Primary LanguageJavaScript

joi-traverse

joi has no internal api, but it's utility for generative tasks is undeniable. I built some joi utilities... but using an undocumented interfaces means, eventually, something will break. binding a specific joi version to a traversal API allows me to prevent this by upgrading the traversal code in lock step with the joi version.

Usage

const {Walker} = require('joi-traverse');
const Subwalker = Walker.extend({
    //creates leaf nodes (objects/arrays automatically handled)
    make : function(schema, generator, fieldName){
        //return value;
    }
});
let walker = new Subwalker(joiDefinition);
let processed = walker.traverse('SEED');