Changed types in schema for attributedValue and value to accept multiple types

This commit is contained in:
alexandercerutti
2018-08-27 16:24:05 +02:00
parent b8e6eec016
commit 854ceddb04

View File

@@ -23,13 +23,13 @@ let barcode = Joi.object().keys({
}); });
let field = Joi.object().keys({ let field = Joi.object().keys({
attributedValue: Joi.string().allow(""), attributedValue: Joi.alternatives(Joi.string().allow(""), Joi.number(), Joi.date().iso()),
changeMessage: Joi.string().allow("").regex(/%@/), changeMessage: Joi.string().allow("").regex(/%@/),
dataDetectorType: Joi.array().items(Joi.string().regex(/(PKDataDetectorTypePhoneNumber|PKDataDetectorTypeLink|PKDataDetectorTypeAddress|PKDataDetectorTypeCalendarEvent)/, "dataDetectorType")), dataDetectorType: Joi.array().items(Joi.string().regex(/(PKDataDetectorTypePhoneNumber|PKDataDetectorTypeLink|PKDataDetectorTypeAddress|PKDataDetectorTypeCalendarEvent)/, "dataDetectorType")),
label: Joi.string().allow(""), label: Joi.string().allow(""),
textAlignment: Joi.string().regex(/(PKTextAlignmentLeft|PKTextAlignmentCenter|PKTextAlignmentRight|PKTextAlignmentNatural)/, "graphic-alignment"), textAlignment: Joi.string().regex(/(PKTextAlignmentLeft|PKTextAlignmentCenter|PKTextAlignmentRight|PKTextAlignmentNatural)/, "graphic-alignment"),
key: Joi.string().required(), key: Joi.string().required(),
value: Joi.string().allow("").required() value: Joi.alternatives(Joi.string().allow(""), Joi.number(), Joi.date().iso()).required()
}); });
let beaconsDict = Joi.object().keys({ let beaconsDict = Joi.object().keys({
@@ -70,7 +70,7 @@ module.exports = {
let validation = Joi.validate(opts, schemaName); let validation = Joi.validate(opts, schemaName);
if (validation.error) { if (validation.error) {
debug(`validation failed due to :: ${validation.error.message}`); debug(`validation failed due to error: ${validation.error.message}`);
} }
return !validation.error; return !validation.error;