<commit_before><?php

class MY_Form_validation extends CI_Form_validation
{
    /**
     * Determines if $value already exists in the $column of $table.
     *
     * @param string $value value to check for uniqueness in DB
     * @param string $table the Doctrine table containing $column
     * @param string $column the column to check
     * @param int $id the
     * @return bool $id true if the value is unique
     */
    function is_unique_or_existing($value, $table, $column, $id)
    {
        if (isset($id) AND ($id <= 0)) {
            return false;
        }
        $result = Doctrine_Query::create()
            ->from($table)
            ->select('id')
            ->where("$column = ?", $value)
            ->execute();

        if ($result->count() == 0) {
            return true; // it's a unique name
        } else {
            // There was a match, find out if it is just the submitted item or
            // a dupe. Assuming that the database had just 1 match, this loop
            // should only execute once, but let's be safe just in case.
            foreach ($result as $row) {
                if ($row->id != $id) {
                    // id mismatch, this would have created a multiple
                    return false;
                }
            }
            // this is an edit, let it pass
            return true;
        }
    }

    function valid_date($date) {
        $tdate = trim($date);
        if (! preg_match('/^\d\d\d\d[-]\d\d[-]\d\d$/', $tdate) ) {
            return false;
        }
        list($year, $month, $day) = explode('-', $tdate);
        return checkdate($month, $day, $year);
    }

    function alpha_dot_dash($val)
    {
        return (!preg_match("/^([\.-a-z0-9_-])+$/i", $val)) ? FALSE : TRUE;
    }

    function noreq_numeric($val)
    {
        if ($val == '' || is_numeric($val)) {
            return true;
        }

        $this->set_message(__FUNCTION__, 'The %s field must be a number.');
        return false;
    }
<commit_msg>Fix error messages for valid_date<commit_after><?php

class MY_Form_validation extends CI_Form_validation
{
    /**
     * Determines if $value already exists in the $column of $table.
     *
     * @param string $value value to check for uniqueness in DB
     * @param string $table the Doctrine table containing $column
     * @param string $column the column to check
     * @param int $id the
     * @return bool $id true if the value is unique
     */
    function is_unique_or_existing($value, $table, $column, $id)
    {
        if (isset($id) AND ($id <= 0)) {
            return false;
        }
        $result = Doctrine_Query::create()
            ->from($table)
            ->select('id')
            ->where("$column = ?", $value)
            ->execute();

        if ($result->count() == 0) {
            return true; // it's a unique name
        } else {
            // There was a match, find out if it is just the submitted item or
            // a dupe. Assuming that the database had just 1 match, this loop
            // should only execute once, but let's be safe just in case.
            foreach ($result as $row) {
                if ($row->id != $id) {
                    // id mismatch, this would have created a multiple
                    return false;
                }
            }
            // this is an edit, let it pass
            return true;
        }
    }

    function valid_date($date) {
        $tdate = trim($date);

        if (! preg_match('/^\d\d\d\d[-]\d\d[-]\d\d$/', $tdate) ) {
            $this->set_message(__FUNCTION__,
                'The %s field must be of the form YYYY-MM-DD.');
            return false;
        }

        list($year, $month, $day) = explode('-', $tdate);
        $validDate = checkdate($month, $day, $year);

        if ($validDate) {
            return true;
        }

        $this->set_message(__FUNCTION__, 'The %s field is not a valid date');
        return false;
    }

    function alpha_dot_dash($val)
    {
        return (!preg_match("/^([\.-a-z0-9_-])+$/i", $val)) ? FALSE : TRUE;
    }

    function noreq_numeric($val)
    {
        if ($val == '' || is_numeric($val)) {
            return true;
        }

        $this->set_message(__FUNCTION__, 'The %s field must be a number.');
        return false;
    }

{'fraction_non_alphanumeric': 0.1333024762786392, 'fraction_numerical': 0.0023142791020597086, 'mean_word_length': 1.6450428396572827, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '231287', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1234, 'n_words': 403}