You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
841 B
JavaScript
23 lines
841 B
JavaScript
"use strict";
|
|
|
|
const required = require("@validatem/required");
|
|
const isString = require("@validatem/is-string");
|
|
const arrayOf = require("@validatem/array-of");
|
|
|
|
const isTimelineEvent = require("../is-timeline-event");
|
|
const isStateEvent = require("../is-state-event");
|
|
const optionalArray = require("../optional-array");
|
|
|
|
module.exports = function isMessagesResponse(strict = false, extraFields = {}) {
|
|
// FIXME: Expand validation rules affected by 'strict' setting? eg. allowing extra properties in the messages response itself
|
|
let isTimelineList = arrayOf([ required, isTimelineEvent(strict, extraFields) ]);
|
|
let isStateList = arrayOf([ required, isStateEvent(strict, extraFields) ]);
|
|
|
|
return {
|
|
start: [ required, isString ],
|
|
end: [ isString ],
|
|
chunk: optionalArray(isTimelineList),
|
|
state: optionalArray(isStateList)
|
|
};
|
|
};
|