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

dynogels.types.uuid() returning an Object #36

Closed
charlesnoble opened this issue Oct 17, 2016 · 9 comments · Fixed by #40
Closed

dynogels.types.uuid() returning an Object #36

charlesnoble opened this issue Oct 17, 2016 · 9 comments · Fixed by #40
Labels

Comments

@charlesnoble
Copy link

Reinstalled my node_modules folder for the first time in 17 days and suddenly dynogels.types.uuid() is not returning a UUID, but returning an Object for some strange reason.

I kept receiving the error:

error: 'child "id" fails because ["id" must be a string] on ...

and on further investigation, id looked like:

     id: 
      { '0': 46,
        '1': 122,
        '2': 34,
        '3': 227,
        '4': 36,
        '5': 212,
        '6': 68,
        '7': 24,
        '8': 164,
        '9': 166,
        '10': 226,
        '11': 139,
        '12': 86,
        '13': 61,
        '14': 108,
        '15': 195,
        abortEarly: false,
        convert: true,
        allowUnknown: false,
        skipFunctions: false,
        stripUnknown: false,
        language: {},
        presence: 'optional',
        strip: false,
        noDefaults: false },

and my schema file looks like:

var schema = {
  id: dynogels.types.uuid(),

Not sure where this has come from and nothing else has changed and it was all previously working very well.

Thanks for the help! 👍

@clarkie
Copy link
Owner

clarkie commented Oct 17, 2016

Hi, can you post your package.json file please? What version of Joi and Dynogels are you using?

@charlesnoble
Copy link
Author

charlesnoble commented Oct 17, 2016

Wow, straight on it, great work!

package.json:

  "dependencies": {
    "dynogels": "^5.0.2",
    "joi": "^9.0.1",
  },

I tried updating both Joi and Dynogels, but the same issue.

@cdhowie
Copy link
Collaborator

cdhowie commented Oct 17, 2016

The object shown looks suspiciously like the Joi options object. Can you post an MCVE of the issue?

I can't reproduce the behavior on my end; the type works as I would expect:

> require('.').types.uuid().validate();
{ error: null, value: '1c6102e1-b896-434e-a9f1-66d7016bc732' }

@charlesnoble
Copy link
Author

I can reproduce those results too:

  let test = dynogels.types.uuid().validate();
  console.log(test)

Outputs:

{ error: null, value: '421ea917-c879-4d43-9d6b-ee1d72c11a22' }

I'll investigate more today and see what I can find.

@charlesnoble
Copy link
Author

Temporarily I've implemented:

import { generateUUID } from '../utils/short-hash'

var schema = {
  id: Joi.string().guid().default(generateUUID),

and in short-hash.js:

import nodeUUID from 'node-uuid'

export let generateUUID = (context) => {
    return nodeUUID.v4()
}

generateUUID.description = 'uuid v4'

That seems to be working. I'll try to continue debugging the other issue later tomorrow.

@csi-lk
Copy link

csi-lk commented Oct 19, 2016

Can reproduce this too on my end from a new install

package.json

    "dynogels": "^6.1.0",
    "joi": "^9.2.0",

Any version number I can drop to for the moment?

@dylanswartz
Copy link

Just started having this issue as well on a number of my services:

"dynogels": "^5.1.0",
"joi": "^9.0.4",

Looks like joi 9.2.0 gets installed. Locked it into 9.0.4 for a fix.

@clarkie
Copy link
Owner

clarkie commented Nov 3, 2016

you're right, this seems to break the tests too.
npm i joi@9.0 && npm t
npm i joi@9.1 && npm t
npm i joi@9.2 && npm t
I'm looking into what changed in 9.1

@clarkie
Copy link
Owner

clarkie commented Nov 3, 2016

Thanks for your help with this, I've raised an issue asking for help from the joi lot.

@clarkie clarkie mentioned this issue Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants