<commit_before>var Post = require('./model');
var router = require('express').Router();

function validatePost(req, res, next) {
  // Sanitize Input
  req.sanitizeBody('title').escape();
  req.sanitizeBody('description').escape();
  req.sanitizeBody('slug').escape();
  req.sanitizeBody('published').toBoolean();

  // Validate Input
  req.checkBody('title', 'Invalid title').notEmpty().isLength({min : 0, max : 120});
  req.checkBody('description', 'Invalid description').notEmpty().isLength({min : 0, max : 160});
  req.checkBody('body', 'Invalid content').notEmpty();<commit_msg>Fixed #32 : Slugs automatically converted to lower case<commit_after>var Post = require('./model');
var router = require('express').Router();

function validatePost(req, res, next) {
  // Sanitize Input
  req.sanitizeBody('title').escape();
  req.sanitizeBody('description').escape();
  req.sanitizeBody('slug').escape();
  req.sanitizeBody('published').toBoolean();

  // Make the slug lower case
  req.body.slug = req.body.slug.toLowerCase();

  // Validate Input
  req.checkBody('title', 'Invalid title').notEmpty().isLength({min : 0, max : 120});
  req.checkBody('description', 'Invalid description').notEmpty().isLength({min : 0, max : 160});
  req.checkBody('body', 'Invalid content').notEmpty();
{'fraction_non_alphanumeric': 0.1923676012461059, 'fraction_numerical': 0.014018691588785047, 'mean_word_length': 5.48989898989899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '916369', 'n_tokens_mistral': 392, 'n_tokens_neox': 388, 'n_words': 79}