SteveORiver
SteveORiver

Reputation: 55

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.

Upvotes: 0

Views: 39

Answers (1)

Ankh
Ankh

Reputation: 5738

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')
});

Upvotes: 0

Related Questions