简体   繁体   中英

ArangoDB Fox syntax error declaring schema argument

I have declared a JOI schema/bean and cannot use that definition when declaring another schema/bean?

I get a syntax error on "arg: joi.object.schema(TestBean).required()" but can declare an array using a schema like: "argArray: joi.array().items(TestBean).required()"

const TestBean = joi.object().required().keys({
  member1: joi.array().items(joi.string().required()),
  member2: joi.number().required()
}).unknown(); // allow additional attributes

const BeanMethodDocument = joi.object().required().keys({
  arg: joi.object.schema(TestBean).required(),
  argArray: joi.array().items(TestBean).required(),
  option: joi.string().valid('Empty','Full','HalfFull','HalfEmpty')
});

I am expecting that I can use pre-defined declarations of schemas. I just need the proper syntax.

You're missing the function call on joi.object .

const BeanMethodDocument = joi.object().required().keys({
    arg: joi.object().schema(TestBean).required(),
    // ------------^
    argArray: joi.array().items(TestBean).required(),
    option: joi.string().valid('Empty','Full','HalfFull','HalfEmpty')
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM