Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
node-oauth2-server/lib/validator/is.js /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
81 lines (66 sloc)
1.75 KB
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
| 'use strict'; | |
| /** | |
| * Validation rules. | |
| */ | |
| var rules = { | |
| NCHAR: /^[\u002D|\u002E|\u005F|\w]+$/, | |
| NQCHAR: /^[\u0021|\u0023-\u005B|\u005D-\u007E]+$/, | |
| NQSCHAR: /^[\u0020-\u0021|\u0023-\u005B|\u005D-\u007E]+$/, | |
| UNICODECHARNOCRLF: /^[\u0009|\u0020-\u007E|\u0080-\uD7FF|\uE000-\uFFFD|\u10000-\u10FFFF]+$/, | |
| URI: /^[a-zA-Z][a-zA-Z0-9+.-]+:/, | |
| VSCHAR: /^[\u0020-\u007E]+$/ | |
| }; | |
| /** | |
| * Export validation functions. | |
| */ | |
| module.exports = { | |
| /** | |
| * Validate if a value matches a unicode character. | |
| * | |
| * @see https://tools.ietf.org/html/rfc6749#appendix-A | |
| */ | |
| nchar: function(value) { | |
| return rules.NCHAR.test(value); | |
| }, | |
| /** | |
| * Validate if a value matches a unicode character, including exclamation marks. | |
| * | |
| * @see https://tools.ietf.org/html/rfc6749#appendix-A | |
| */ | |
| nqchar: function(value) { | |
| return rules.NQCHAR.test(value); | |
| }, | |
| /** | |
| * Validate if a value matches a unicode character, including exclamation marks and spaces. | |
| * | |
| * @see https://tools.ietf.org/html/rfc6749#appendix-A | |
| */ | |
| nqschar: function(value) { | |
| return rules.NQSCHAR.test(value); | |
| }, | |
| /** | |
| * Validate if a value matches a unicode character excluding the carriage | |
| * return and linefeed characters. | |
| * | |
| * @see https://tools.ietf.org/html/rfc6749#appendix-A | |
| */ | |
| uchar: function(value) { | |
| return rules.UNICODECHARNOCRLF.test(value); | |
| }, | |
| /** | |
| * Validate if a value matches generic URIs. | |
| * | |
| * @see http://tools.ietf.org/html/rfc3986#section-3 | |
| */ | |
| uri: function(value) { | |
| return rules.URI.test(value); | |
| }, | |
| /** | |
| * Validate if a value matches against the printable set of unicode characters. | |
| * | |
| * @see https://tools.ietf.org/html/rfc6749#appendix-A | |
| */ | |
| vschar: function(value) { | |
| return rules.VSCHAR.test(value); | |
| } | |
| }; |