-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add JWTExpired error and JWTClaimInvalid claim and reason props
Resolves #62
- Loading branch information
Showing
6 changed files
with
253 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const isNotString = val => typeof val !== 'string' || val.length === 0 | ||
|
||
module.exports.isNotString = isNotString | ||
module.exports.isString = function isString (Err, value, label, required = false) { | ||
module.exports.isString = function isString (Err, value, label, claim, required = false) { | ||
if (required && value === undefined) { | ||
throw new Err(`${label} is missing`) | ||
throw new Err(`${label} is missing`, claim, 'missing') | ||
} | ||
|
||
if (value !== undefined && isNotString(value)) { | ||
throw new Err(`${label} must be a string`) | ||
throw new Err(`${label} must be a string`, claim, 'invalid') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.