Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: @hapi/joi
node v10.24.1
version:
1.0.0
endpoint
share
tweet
const Joi = require("@hapi/
[email protected]
") 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