How to use the rtrim function from validator

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

1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
 */
Chain.prototype.rtrim = function(chars) {
  this._pushValidator({
    name: 'rtrim',
    func: function(value, baton, callback) {
      callback(null, check.rtrim(value, chars));
    },
    help: null
  });
  return this;
fork icon11
star icon96
watch icon0

7
8
9
10
11
12
13
14
15
16
sanitizeArray.forEach(sanitizeObj => {
  let sanitizefield = req.body[sanitizeObj.field];
  sanitizefield = !isEmpty(sanitizefield) ? sanitizefield + '' : '';
  const sanitization = sanitizeObj.sanitize;
  if (sanitization.rtrim) {
    sanitizefield = Validator.rtrim(sanitizefield);
  }
  if (sanitization.ltrim) {
    sanitizefield = Validator.ltrim(sanitizefield);
  }
fork icon0
star icon3
watch icon0

97
98
99
100
101
102
103
104
105
106
  && validator.isAscii(profile.firstname)
  && validator.isAscii(profile.lastname)
  && validator.isAscii(profile.country)
) {
  // trim any extra spaces on the right of the name
  profile.firstname = validator.rtrim(profile.firstname)
  profile.lastname = validator.rtrim(profile.lastname)

  // render the view
  return res.render('account.hbs', profile)
fork icon0
star icon0
watch icon1

+ 7 other calls in file

212
213
214
215
216
217
218
219
220
221
}
if (sanitization.ltrim) {
  req.body[field] = Validator.ltrim(req.body[field]);
}
if (sanitization.rtrim) {
  req.body[field] = Validator.rtrim(req.body[field]);
}
if (sanitization.toBoolean) {
  req.body[field] = Validator.toBoolean(req.body[field]);
}
fork icon0
star icon0
watch icon0

+ 11 other calls in file

380
381
382
383
384
385
386
387
388
389
},
'ltrim': {
  converter: V.ltrim
},
'rtrim': {
  converter: V.rtrim
},
'removeHTML': {
  converter: (val) => val.toString().replace(/<(?:.|\n)*?>/gm, '')
},
fork icon0
star icon0
watch icon0