all repos — litestore @ f1832f40b40c48fbb17efe6d15a44c5cf03d6228

A minimalist nosql document store.

src/litestorepkg/examples/middleware/validate.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
(function () {
  var id = $req.path.replace(/^\/docs\//, '');
  var valid = /[A-Z]{2}[0-9]{3}[A-Z]{2}/;
  if (!id.match(valid)) {
    $res.content = {
      error: 'Invalid number plate'
    };
    $res.code = 400;
    return true;
  }
}())