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

var id = Joi.alternatives().when('type', {
    is: 'sayunixtime', then: '', otherwise: Joi.string().required(),
    is: 'registrationuser', then: '', otherwise: Joi.string().required(),
    is: 'registrationoperator', then: '', otherwise: Joi.string().required()
})

var route = {
    standard: Joi.object().keys({
        type: Joi.string().required().valid(types),
        id: id
    }),
    interval: Joi.object().keys({
        type: Joi.string().required().valid(types),
        id: id,
        begin: Joi.string().required(),
        end: Joi.string().required()
    }),
    peergroup: Joi.object().keys({
        type: Joi.string().required().valid(types),
        id: id,
        wait: Joi.string().required(),
        duration: Joi.string().required()
    }),
    key: Joi.object().keys({
        type: Joi.string().required().valid(types),
        id: id,
        key: Joi.string().required()
    }),
    free: Joi.object().keys({
        type: Joi.string().required().valid(types)
    }),
    custom: Joi.object().keys({
        type: Joi.string().required().valid(types),
        id: id
    }),
    day: Joi.object().keys({
        day: Joi.string().required(),
        type: Joi.string().required().valid(types),
        id: id
    })
};

module.exports = route;
@@ -70,21 +70,17 @@
 oi.a
-lternatives()
+ny()%0A    
 .whe
@@ -90,21 +90,16 @@
 type', %7B
-%0A    
 is: 'say
@@ -121,124 +121,84 @@
 : ''
-, otherwise: Joi.string().required(),%0A    is: 'registrationuser', then: '', otherwise: Joi.string().required(),%0A    
+%7D)%0A    .when('type', %7Bis: 'registrationuser', then: ''%7D)%0A    .when('type', %7B
 is: 
@@ -269,11 +269,11 @@
 ed()
-%0A
 %7D)
+;
 %0A%0Ava

fix required id