lib/index.js
function plugin(options) {
    if (!options || typeof options !== 'object') {
        throw new Error('AjvMoment#plugin requires options');
    }
    if (!options.ajv) {
        throw new Error(`AjvMoment#plugin options requries an 'ajv' attribute (ajv instance)`);
    }
    if (!options.moment) {
        throw new Error(`AjvMoment#plugin options requries a 'moment' attribute (moment.js)`);
    }
    const { ajv, moment } = options;
    ajv.moment = moment;
    const keywordSettings = {
        type: 'string',
        statements: true,
        errors: true,
        inline
    };
    if (ajv) {
        ajv.addKeyword('moment', keywordSettings);
    }
    return keywordSettings;
}
function plugin(options) {
    if (!options || typeof options !== 'object') {
        throw new Error('AjvMoment#plugin requires options');
    }
    if (!options.ajv) {
        throw new Error(`AjvMoment#plugin options requries an 'ajv' attribute (ajv instance)`);
    }
    if (!options.moment) {
        throw new Error(`AjvMoment#plugin options requries a 'moment' attribute (moment.js)`);
    }
    const { ajv, moment } = options;
    ajv.moment = moment;
    const keywordSettings = {
        type: 'string',
        statements: true,
        errors: true,
        inline
    };
    if (ajv) {
        ajv.addKeyword('moment', keywordSettings);
    }
    return keywordSettings;
}
function plugin ( options ) { if ( ! options || typeof options !== 'object' ) { throw new Error ( 'AjvMoment#plugin requires options' ) ; } if ( ! options . ajv ) { throw new Error ( ` ` ) ; } if ( ! options . moment ) { throw new Error ( ` ` ) ; } const { ajv , moment } = options ; ajv . moment = moment ; const keywordSettings = { type : 'string' , statements : true , errors : true , inline } ; if ( ajv ) { ajv . addKeyword ( 'moment' , keywordSettings ) ; } return keywordSettings ; }
Configure the plugin by attaching moment to the ajv instance and defining the
'moment' custom keyword
@param  {Object} options - plugin options
@return {Object} keywordSettings
Configure the plugin by attaching moment to the ajv instance and defining the moment custom keyword