Giter Site home page Giter Site logo

uuid-validate's Introduction

uuid-validator

Build Status

Useful little package to validate UUIDs in Node.js. Usage:

var validate = require('uuid-validate');

// Let's validate a uuid version 1. If we don't pass a version, it'll
// infer it based on the uuid itself.
validate('95ecc380-afe9-11e4-9b6c-751b66dd541e'); // => true

// We can tell it what version to expect, and if it gets the wrong
// version, it'll return false.
validate('95ecc380-afe9-11e4-9b6c-751b66dd541e', 1); // => true (it's version 1)
validate('95ecc380-afe9-11e4-9b6c-751b66dd541e', 4); // => false (it's not version 4)

// You can also pass buffers instead of strings.
// This works for UUID versions 1 through 4

// If you want to find out what version a UUID is:
validate.version('95ecc380-afe9-11e4-9b6c-751b66dd541e'); // => 1

uuid-validate's People

Contributors

alfw avatar alisoleimani avatar connor4312 avatar sidhuko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uuid-validate's Issues

version() returns false positives for strings that are too large

Maybe this is not how the library is intended to be used. If that is the case, then please close.

Steps to reproduce

var uuidValidate = require("uuid-validate")

// Behaves as expected
uuidValidate('b38d63b5-524f-468c-b1c8-942c8c2284325') // => false

uuidValidate.version('b38d63b5-524f-468c-b1c8-942c8c2284325') // => 4

Expected behavior

Would it make sense to have version() also return false if the UUID is invalid?

does v4 validation really work?

> var validate = require('uuid-validate');
> var uuid = require('node-uuid');
> var u = uuid.v4()
> validate(u)
false
> u
'97a90793-4898-4abe-b255-e8dc6967ed40'
> validate(u,4)
false
> validate(u,1)
true
> validate.version(u)
4

As you can see, it validates as version 1, but validate.version() returns version 4. Something isn't right.

ReferenceError: Buffer is not defined

import validate from "uuid-validate";

....
....
const id = 'b8283d-7b7d-4e32-b3ce-81844e2b3c83';
console.log(validate(id));

throwing error: Uncaught ReferenceError: Buffer is not defined

Valid uuid marked as invalid

I've found an instance of a valid v3 uuid that gets identified as non valid, 4810935e-168b-3d7d-7a42-081999ff18bb. I've checked multiple tools and all seem to agree that this is indeed a valid uuid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.