- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 54
Replaces jshint with eslint #30
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 5 commits
      Commits
    
    
            Show all changes
          
          
            11 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      e650264
              
                removed jshint added eslint
              
              
                jwerre 9ebf817
              
                merge with development branch
              
              
                jwerre 0cf3b11
              
                removed 'no-prototype-builtins' from eslint
              
              
                jwerre b4e344d
              
                tests validator is tested for all unicode ranges
              
              
                jankapunkt f57f4c3
              
                validator is add missing variable in is.uchar
              
              
                jankapunkt 615bd75
              
                tests validator also test for multiple characters
              
              
                jankapunkt c0e4ef1
              
                eslint enable no-control-regex and disable only in validator
              
              
                jankapunkt 9775b39
              
                tests validator is increase timeout
              
              
                jankapunkt 391fbef
              
                added chai to is_test.js
              
              
                jwerre 2e4d14f
              
                removed jshint
              
              
                jwerre 12f0a80
              
                disallow the use of console
              
              
                jwerre File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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 | 
|---|---|---|
|  | @@ -31,7 +31,6 @@ | |
| "error", | ||
| "always" | ||
| ], | ||
| "no-control-regex": "off", | ||
| "no-console": "off", | ||
| "no-unused-vars": [ | ||
| "error", | ||
|  | ||
  
    
      This file contains hidden or 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 hidden or 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 | 
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| var is = require('../../../lib/validator/is'); | ||
| require('should'); | ||
|  | ||
| function runRanges (ranges, fn, expected) { | ||
| ranges.forEach(function (range) { | ||
| var lower = range[0]; | ||
| var upper = range[1]; | ||
|  | ||
| for (var i = lower; i <= upper; i++) { | ||
| var unicodeChar = String.fromCodePoint(i); | ||
| // single char | ||
| fn(unicodeChar).should.eql(expected, i + ' ' + unicodeChar); | ||
| // multiple chars | ||
| fn(unicodeChar+unicodeChar).should.eql(expected, i + ' ' + unicodeChar); | ||
| } | ||
| }); | ||
| } | ||
|  | ||
| describe('Validator', function () { | ||
| describe('is', function () { | ||
| it('validates if a value matches a unicode character (nchar)', function () { | ||
| var validRanges = [ | ||
| [45, 46], // \u002D \u002E | ||
| [48, 57], // 0-9 | ||
| [65, 90], // A-Z | ||
| [95, 95], // \u005F | ||
| [97, 122] // a-z | ||
| ]; | ||
|  | ||
| runRanges(validRanges, is.nchar, true); | ||
|  | ||
| var invalidRanges = [ | ||
| [0, 44], | ||
| [47, 47], | ||
| [58, 64], | ||
| [91, 94], | ||
| [96, 96], | ||
| [123, 1023] | ||
| ]; | ||
|  | ||
| runRanges(invalidRanges, is.nchar, false); | ||
| }); | ||
| it('validates if a value matches a unicode character, including exclamation marks (nqchar)', function () { | ||
| var validRanges = [ | ||
| [33, 33], // \u0021 | ||
| [35, 91], // \u0023-\u005B | ||
| [93, 126] // \u005D-\u007E | ||
| ]; | ||
|  | ||
| runRanges(validRanges, is.nqchar, true); | ||
|  | ||
| var invalidRanges = [ | ||
| [0, 32], | ||
| [34, 34], | ||
| [92, 92], | ||
| [127, 1023] | ||
| ]; | ||
|  | ||
| runRanges(invalidRanges, is.nqchar, false); | ||
| }); | ||
| it('validates if a value matches a unicode character, including exclamation marks and spaces (nqschar)', function () { | ||
| var validRanges = [ | ||
| [32, 33], // \u0020-\u0021 | ||
| [35, 91], // \u0023-\u005B | ||
| [93, 126] // \u005D-\u007E | ||
| ]; | ||
|  | ||
| runRanges(validRanges, is.nqschar, true); | ||
|  | ||
| var invalidRanges = [ | ||
| [0, 31], | ||
| [34, 34], | ||
| [92, 92], | ||
| [127, 1023] | ||
| ]; | ||
|  | ||
| runRanges(invalidRanges, is.nqschar, false); | ||
| }); | ||
| it('validates if a value matches a unicode character excluding the carriage return and linefeed characters (uchar)', function () { | ||
| this.timeout(60000); | ||
| var validRanges = [ | ||
| [9, 9], // \u0009 | ||
| [32, 126], // \u0020-\u007E, | ||
| [128, 55295], // \u0080-\uD7FF | ||
| [57344, 65533], // \uE000-\uFFFD | ||
| [65536, 1114111] // \u10000-\u10FFFF | ||
| ]; | ||
|  | ||
| runRanges(validRanges, is.uchar, true); | ||
|  | ||
| var invalidRanges = [ | ||
| [0, 8], | ||
| [10, 31], | ||
| [127, 127], | ||
| [55296, 57343], | ||
| [65534, 65535] | ||
| ]; | ||
|  | ||
| runRanges(invalidRanges, is.uchar, false); | ||
| }); | ||
| it('validates if a value matches generic URIs (uri)', function () { | ||
| ['aa:', 'http:', 'https:'].forEach(function (uri) { | ||
| is.uri(uri).should.equal(true); | ||
| is.uri(uri.toUpperCase()).should.equal(true); | ||
| }); | ||
|  | ||
| ['a', 'a:', 'http'].forEach(function (uri) { | ||
| is.uri(uri).should.equal(false); | ||
| is.uri(uri.toUpperCase()).should.equal(false); | ||
| }); | ||
| }); | ||
| it('validates if a value matches against the printable set of unicode characters (vschar)', function () { | ||
| var validRanges = [ | ||
| [32, 126] // \u0020-\u007E | ||
| ]; | ||
|  | ||
| runRanges(validRanges, is.vschar, true); | ||
|  | ||
| var invalidRanges = [ | ||
| [0, 31], | ||
| [127, 1023] | ||
| ]; | ||
|  | ||
| runRanges(invalidRanges, is.vschar, false); | ||
| }); | ||
| }); | ||
| }); | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.