RunKit + npm: @hapi/joi

node v10.18.0
version: 1.0.0
endpointsharetweet
const Joi = require("@hapi/joi@15.1.1") const { expect } = require('@hapi/code') const data = { from: new Date('2020-04-02'), to: new Date('2020-04-01') } //const schemaWorking = Joi.object({ // from: Joi.date(), // to: Joi.date().min(Joi.ref('from')) //}) const schemaFailing = Joi.object({ from: Joi.date(), to: Joi.when('from', { is: Joi.string(), then: Joi.date().min(Joi.ref('from')), else: Joi.date().min(Joi.ref('from')) }) }) //const { error: working } = Joi.validate(data, schemaWorking) const { error: failing } = Joi.validate(data, schemaFailing) expect(failing).to.exist()
Created from: https://npm.runkit.com/%40hapi%2Fjoi
Loading…

no comments

    sign in to comment