Test Failed
Pull Request — master (#2)
by Yo
01:40
created

lib/server/models/request.js   A

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 35
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 35
rs 10
wmc 0
mnd 0
bc 0
fnc 0
bpm 0
cpm 0
noi 0
1
"use strict";
2
3
const Joi = require('joi');
4
5
module.exports = Joi.object()
6
    .keys({
7
        method: Joi.string()
8
            .allow(['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])
9
            .default('GET'),
10
        uri: Joi.string()
11
            .uri({
12
                scheme: [/https?/]
13
            })
14
            .required(),
15
        payload: Joi.when('json', {
16
            is: true,
17
            then: Joi.alternatives().try(Joi.object(), Joi.array()),
18
            otherwise: Joi.string()
19
        }),
20
        queryString: Joi.object(),
21
        headers: Joi.object(),
22
        form: Joi.alternatives().try(Joi.object(), Joi.array()),
23
        json: Joi.boolean()
24
            .default(true)
25
    })
26
    .example({
27
        method: 'GET',
28
        uri: 'http://url.com',
29
        payload: {},
30
        queryString: {},
31
        headers: {},
32
        form: {},
33
        json: true
34
    })
35
;
36