<commit_before>'use strict';

var logger = require('logger');
var JSONAPISerializer = require('jsonapi-serializer').Serializer;
var slug = require('slug');
slug.defaults.modes.pretty = {
    replacement: '_',
    symbols: true,
    remove: /[.]/g,
    lower: false,
    charmap: slug.charmap,
    multicharmap: slug.multicharmap
};


class ErrorSerializer {

    static serializeValidationError(data, typeParam) {
        let keys = Object.keys(data);
        var message = '';
        switch(typeParam) {
        case 'body':
            message = 'Invalid body parameter';
            break;
        case 'query':
            message = 'Invalid query parameter';
            break;
        default:
            message = '';
        }
        return {
            source: {
                parameter: keys[0]
            },
            code: slug(message).toLowerCase(),
            title: message,
            detail: data[keys[0]]
        };
    }

    static serializeValidationBodyErrors(data) {<commit_msg>fix slug<commit_after>'use strict';

var logger = require('logger');
var JSONAPISerializer = require('jsonapi-serializer').Serializer;



class ErrorSerializer {

    static serializeValidationError(data, typeParam) {
        let keys = Object.keys(data);
        var message = '';
        switch(typeParam) {
        case 'body':
            message = 'Invalid body parameter';
            break;
        case 'query':
            message = 'Invalid query parameter';
            break;
        default:
            message = '';
        }
        return {
            source: {
                parameter: keys[0]
            },
            code: message.replace(/ /g, '_').toLowerCase(),
            title: message,
            detail: data[keys[0]]
        };
    }

    static serializeValidationBodyErrors(data) {
{'fraction_non_alphanumeric': 0.11632987438558165, 'fraction_numerical': 0.002184598580010923, 'mean_word_length': 1.8271604938271604, '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': '5921621', 'n_tokens_mistral': 489, 'n_tokens_neox': 481, 'n_words': 112}