<commit_before>'use strict';

const moment = require('moment');
const _ = require('underscore');

const DATE_PARTS = ['day', 'month', 'year'];

module.exports = Controller => class extends Controller {
    configure(req, res, next) {
        req.form.options.dateFields = _.keys(_.pick(
            req.form.options.fields,
            field => field.validate === 'date' || _.contains(field.validate, 'date'))
        );

        _.forEach(req.form.options.dateFields, fieldName => this.configureDateField(req, fieldName));

        super.configure(req, res, next);
    }

    configureDateField(req, fieldName) {
        let dateField = req.form.options.fields[fieldName];
        let required = _.contains(dateField.validate, 'required');

        DATE_PARTS.forEach(part => {
            // get any existing date part field options
            let field = req.form.options.fields[fieldName + '-' + part];

            field = _.extend({
                errorGroup: fieldName,
                hintId: fieldName + '-hint',<commit_msg>Set content key for date parts to be generic<commit_after>'use strict';

const moment = require('moment');
const _ = require('underscore');

const DATE_PARTS = ['day', 'month', 'year'];

module.exports = Controller => class extends Controller {
    configure(req, res, next) {
        req.form.options.dateFields = _.keys(_.pick(
            req.form.options.fields,
            field => field.validate === 'date' || _.contains(field.validate, 'date'))
        );

        _.forEach(req.form.options.dateFields, fieldName => this.configureDateField(req, fieldName));

        super.configure(req, res, next);
    }

    configureDateField(req, fieldName) {
        let dateField = req.form.options.fields[fieldName];
        let required = _.contains(dateField.validate, 'required');

        DATE_PARTS.forEach(part => {
            // get any existing date part field options
            let field = req.form.options.fields[fieldName + '-' + part];

            field = _.extend({
                errorGroup: fieldName,
                hintId: fieldName + '-hint',
                contentKey: 'date-' + part,
{'fraction_non_alphanumeric': 0.13706293706293707, 'fraction_numerical': 0.0, 'mean_word_length': 2.5296052631578947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4395752', 'n_tokens_mistral': 598, 'n_tokens_neox': 575, 'n_words': 136}