Skip to content

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

@minnat

Description

@minnat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions