3 exports.username = username
5 var requirements = exports.requirements = {
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 "."'
14 valid: 'Email must be an email address'
18 function username (un) {
19 if (un !== un.toLowerCase()) {
20 return new Error(requirements.username.lowerCase)
23 if (un !== encodeURIComponent(un)) {
24 return new Error(requirements.username.urlSafe)
27 if (un.charAt(0) === '.') {
28 return new Error(requirements.username.dot)
31 if (un.length > 214) {
32 return new Error(requirements.username.length)
39 if (!em.match(/^.+@.+\..+$/)) {
40 return new Error(requirements.email.valid)