How to use the isBase64 function from validator

Find comprehensive JavaScript validator.isBase64 code examples handpicked from public code repositorys.

15
16
17
18
19
20
21
22
23
24
const imagedata = req.body.image
const country_code = (req.body.country_code) ? validator.escape(req.body.country_code) : 'eu'
const pattern_code = (req.body.pattern_code) ? '-p ' + validator.escape(req.body.pattern_code) : ''

/* Validate input */
if (!imagedata || validator.isBase64(imagedata)) {
  return res.status(500).json({
    error: 'No image sent',
    version: version
  })
fork icon6
star icon4
watch icon2

29
30
31
32
33
34
35
36
37
38
this.isBase32 = (subject) => {
    return StringValidator.isBase32(subject) ? null : subject + ' is not base32';
}

this.isBase64 = (subject) => {
    return StringValidator.isBase64(subject) ? null : subject + ' is not base64';
}

this.isBefore = (date) => (subject) => {
    return StringValidator.isBefore(subject, date) ? null : subject + ' is not before' + date;
fork icon1
star icon4
watch icon2

+ 3 other calls in file

19
20
21
22
23
24
25
26
27
28
console.log('6b3a2b30-f2ee-11e4-b939-0800200c9a66\n', 'isUUID', validator.isUUID('6b3a2b30-f2ee-11e4-b939-0800200c9a66'));
console.log('6b3a2b30-f2ee-11e4-b939\n', 'isUUID', validator.isUUID('6b3a2b30-f2ee-11e4-b939'));


console.log('YXNkYXNkc2R2YWFzbG5rc2FkbnZsc2EnZHY=\n', 'isBase64', validator.isBase64('YXNkYXNkc2R2YWFzbG5rc2FkbnZsc2EnZHY='));
console.log('asdasdsdvaaslnksadnvlsa"dv\n', 'isBase64', validator.isBase64('asdasdsdvaaslnksadnvlsa"dv'));


console.log('ccc\n', 'isHexColor', validator.isHexColor('ccc'));
console.log('ggg0000\n', 'isHexColor', validator.isHexColor('ggg0000'));
fork icon15
star icon3
watch icon4

+ 3 other calls in file

95
96
97
98
99
100
101
102
103
104
        if (len < 5 || len > 5) {
            return false; 
        }
    }

    return dotSplit.reduce((acc, currElem) => acc && validator.isBase64(currElem, { urlSafe: true }), true);

} catch(error) {
    console.log(error.message);
}
fork icon2
star icon3
watch icon0

+ 4 other calls in file

68
69
70
71
72
73
74
75
76
77
  }
  return true;
},
isBase64: function(rule, value) {
  if (rule) {
    return validator.isBase64(value);
  }
  return true;
},
isHexadecimal: function(rule, value) {
fork icon0
star icon2
watch icon2

+ 5 other calls in file

78
79
80
81
82
83
84
85
86
87
    'Detected localhost registry - rejecting npmrc file'
  );
  npmrc = existingNpmrc;
  return;
}
if (key !== '_auth' && key.endsWith('_auth') && isBase64(val)) {
  logger.debug('Massaging _auth to _authToken');
  npmrc[key + 'Token'] = val;
  npmrc.massagedAuth = true;
  delete npmrc[key];
fork icon0
star icon2
watch icon8

+ 3 other calls in file

28
29
30
31
32
33
34
35
36
37
        console.error('Error: Please run command, steedos source:config');
    }else{
        console.error(body);
    }
}else{
    const isBase64 = validator.isBase64(body);
    // console.log("isBase64",isBase64);
    if(!isBase64){
        console.error('Error: metadata-api not detected, enable metadata-api first');
    }else{
fork icon312
star icon0
watch icon41