Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError [ERR_ASSERTION]: you must provide a joi schema #11

Open
minnat opened this issue Sep 9, 2020 · 0 comments
Open

AssertionError [ERR_ASSERTION]: you must provide a joi schema #11

minnat opened this issue Sep 9, 2020 · 0 comments

Comments

@minnat
Copy link

minnat commented Sep 9, 2020

I am writing a simple chargePoint that sends a websocket to the centralSystem. I took the code from the examples and this is where I am facing issues with:

    const boot = new OCPPCommands.BootNotification({
      chargePointVendor: 'BrandX',
      chargeBoxSerialNumber: 'SR' + Math.round(Math.random() * 100000),
      chargePointSerialNumber: '123',
      chargePointModel: '12'
    });

    let answer = await client.send(boot);

OCPPCommands.BootNotification tries to validate the payload with applyPropertiesValidators and it failed to validate with Joi, specifically on this line:

// node_modules/ocpp-eliftech/node_modules/joi/lib/index.js
Hoek.assert(schema && schema instanceof Any, 'you must provide a joi schema');

This is what schema looks like before it fails the schema instanceof Any validation:

{ isJoi: true,
  _currentJoi:
   { isJoi: true,
     _currentJoi:
      { isJoi: true,
        _currentJoi: [Circular],
        _type: 'any',
        _settings: null,
        _baseType: undefined,
        _valids: [InternalSet],
        _invalids: [InternalSet],
        _tests: [],
        _refs: [],
        _flags: {},
        _description: null,
        _unit: null,
        _notes: [],
        _tags: [],
        _examples: [],
        _meta: [],
        _inner: {},
        any: [Function],
        alt: [Function],
        alternatives: [Function],
        array: [Function],
        bool: [Function],
        boolean: [Function],
        binary: [Function],
        date: [Function],
        func: [Function],
        number: [Function],
        object: [Function],
        string: [Function],
        symbol: [Function],
        ref: [Function],
        isRef: [Function],
        validate: [Function],
        describe: [Function],
        compile: [Function],
        assert: [Function],
        attempt: [Function],
        reach: [Function],
        lazy: [Function],
        defaults: [Function],
        extend: [Function],
        extensionSchema: [Object],
        extensionsSchema: [Object],
        version: '13.7.0' },
     _type: 'any',
     _settings: null,
     _baseType: undefined,
     _valids: InternalSet { _set: Set {}, _hasRef: false },
     _invalids: InternalSet { _set: Set {}, _hasRef: false },
     _tests: [],
     _refs: [],
     _flags: {},
     _description: null,
     _unit: null,
     _notes: [],
     _tags: [],
     _examples: [],
     _meta: [],
     _inner: {},
     any: [Function],
     alt: [Function],
     alternatives: [Function],
     array: [Function],
     bool: [Function],
     boolean: [Function],
     binary: [Function],
     date: [Function],
     func: [Function],
     number: [Function],
     object: [Function],
     string: [Function],
     symbol: [Function],
     ref: [Function],
     isRef: [Function],
     validate: [Function],
     describe: [Function],
     compile: [Function],
     assert: [Function],
     attempt: [Function],
     reach: [Function],
     lazy: [Function],
     defaults: [Function],
     extend: [Function],
     extensionSchema:
      { isJoi: true,
        _currentJoi: [Object],
        _type: 'object',
        _settings: [Object],
        _baseType: undefined,
        _valids: [InternalSet],
        _invalids: [InternalSet],
        _tests: [],
        _refs: [],
        _flags: {},
        _description: null,
        _unit: null,
        _notes: [],
        _tags: [],
        _examples: [],
        _meta: [],
        _inner: [Object] },
     extensionsSchema:
      { isJoi: true,
        _currentJoi: [Object],
        _type: 'array',
        _settings: [Object],
        _baseType: undefined,
        _valids: [InternalSet],
        _invalids: [InternalSet],
        _tests: [],
        _refs: [],
        _flags: [Object],
        _description: null,
        _unit: null,
        _notes: [],
        _tags: [],
        _examples: [],
        _meta: [],
        _inner: [Object] },
     version: '13.7.0' },
  _type: 'object',
  _settings: { convert: true },
  _baseType: undefined,
  _valids: InternalSet { _set: Set {}, _hasRef: false },
  _invalids: InternalSet { _set: Set {}, _hasRef: false },
  _tests: [],
  _refs: [],
  _flags: { label: 'BootNotificationRequest' },
  _description: null,
  _unit: null,
  _notes: [],
  _tags: [],
  _examples: [],
  _meta: [],
  _inner:
   { children:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ],
     renames: [],
     dependencies: [],
     patterns: [] } }

I am not sure if this is a dependency issue or there is something missing on my side. Any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant