]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-user-validate/npm-user-validate.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-user-validate / npm-user-validate.js
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 214 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 > 214) {
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 }