Skip to content

Commit

Permalink
fix: allow any guid (swagger-api#4252)
Browse files Browse the repository at this point in the history
* Allow any guid

* Add a few more GUID tests
  • Loading branch information
heldersepu authored and shockey committed Feb 24, 2018
1 parent ba1603a commit d1779dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export const validateDateTime = (val) => {

export const validateGuid = (val) => {
val = val.toString().toLowerCase()
if (!/^[{(]?[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}[)}]?$/.test(val)) {
if (!/^[{(]?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[)}]?$/.test(val)) {
return "Value must be a Guid"
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ describe("utils", function() {
expect(validateGuid("8ce4811e-cec5-4a29-891a-15d1917153c1")).toBeFalsy()
expect(validateGuid("{8ce4811e-cec5-4a29-891a-15d1917153c1}")).toBeFalsy()
expect(validateGuid("8CE4811E-CEC5-4A29-891A-15D1917153C1")).toBeFalsy()
expect(validateGuid("6ffefd8e-a018-e811-bbf9-60f67727d806")).toBeFalsy()
expect(validateGuid("6FFEFD8E-A018-E811-BBF9-60F67727D806")).toBeFalsy()
expect(validateGuid("00000000-0000-0000-0000-000000000000")).toBeFalsy()
})

it("returns a message for invalid input'", function() {
Expand Down

0 comments on commit d1779dc

Please sign in to comment.