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

invalid GUID/UUID is validated as valid #2320

Closed
swantzter opened this issue Mar 20, 2020 · 3 comments
Closed

invalid GUID/UUID is validated as valid #2320

swantzter opened this issue Mar 20, 2020 · 3 comments
Assignees
Labels
feature New functionality or improvement
Milestone

Comments

@swantzter
Copy link

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: v13.11.0
  • module version with issue: v17.1.1
  • last module version without issue: unknown/none
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information: Dashes are required in UUID's as per RFC 4122, page 4
        UUID                   = time-low "-" time-mid "-"
                                 time-high-and-version "-"
                                 clock-seq-and-reserved
                                 clock-seq-low "-" node
    

What are you trying to achieve or the steps to reproduce?

const invalidUUID = '4880367593064f4cab697d01d82b301c'

Joi.string().uuid({ version: 'uuidv4' }).validate(invalidUUID)

example with v4 but should be applicable to all

What was the result you got?

> Object {value: "4880367593064f4cab697d01d82b301c"}

What result did you expect?

> Object {error: exports.ValidationError: "value" must be a valid GUID, value: "4880367593064f4cab697d01d82b301c"}
@swantzter swantzter added the support Questions, discussions, and general support label Mar 20, 2020
@hueniverse hueniverse self-assigned this Jul 6, 2020
@hueniverse hueniverse added feature New functionality or improvement and removed support Questions, discussions, and general support labels Jul 6, 2020
@hueniverse hueniverse added this to the 17.1.2 milestone Jul 6, 2020
@hueniverse
Copy link
Contributor

The validator is flexible and supports a wider range of guids. I added new options to make it strict.

@swantzter
Copy link
Author

Much appreciated, thank you

@rightaway
Copy link

Could separator error message be more specific? Otherwise we might see a failing guid that gives the "not a valid GUID" error and get confused because it looks valid, even though the issue is that it has the wrong kind of separator.

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

No branches or pull requests

3 participants