"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-user-validate/npm-user-validate.js" (7 Feb 2017, 976 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 exports.email = email
    2 exports.pw = pw
    3 exports.username = username
    4 
    5 var requirements = exports.requirements = {
    6   username: {
    7     length: 'Name length must be less than or equal to 576 characters long',
    8     lowerCase: 'Name must be lowercase',
    9     urlSafe: 'Name may not contain non-url-safe chars',
   10     dot: 'Name may not start with "."'
   11   },
   12   password: {},
   13   email: {
   14     valid: 'Email must be an email address'
   15   }
   16 };
   17 
   18 function username (un) {
   19   if (un !== un.toLowerCase()) {
   20     return new Error(requirements.username.lowerCase)
   21   }
   22 
   23   if (un !== encodeURIComponent(un)) {
   24     return new Error(requirements.username.urlSafe)
   25   }
   26 
   27   if (un.charAt(0) === '.') {
   28     return new Error(requirements.username.dot)
   29   }
   30 
   31   if (un.length > 576) {
   32     return new Error(requirements.username.length)
   33   }
   34 
   35   return null
   36 }
   37 
   38 function email (em) {
   39   if (!em.match(/^.+@.+\..+$/)) {
   40     return new Error(requirements.email.valid)
   41   }
   42 
   43   return null
   44 }
   45 
   46 function pw (pw) {
   47   return null
   48 }