Development

#1665 (Improved sfDateValidator)

You must first sign up to be able to contribute.

Ticket #1665 (closed enhancement: fixed)

Opened 6 years ago

Last modified 5 years ago

Improved sfDateValidator

Reported by: bladus Assigned to: fabien
Priority: minor Milestone: 1.1.0
Component: validation Version: 1.0.1
Keywords: sfDateValidator Cc:
Qualification: Unreviewed

Description

Recently i improved the sfDateValidator. New features are:

  • Accept all (strtotime-)date-formats
  • New parameters: min and max
  • The compare-parameter now accepts all strtotime-formats
  • New operator: !=

I also blogged about this on http://symfoniac.wordpress.com

Attached to this ticket is the patch against the sfDateValidator shipped with symfony 1.0.1 and UnitTests? for Lime.

It would be great if this could make it in trunk. Thank you.

Attachments

sfDateValidator.patch (5.2 kB) - added by bladus on 04/13/07 14:34:03.
dateTest.php (5.1 kB) - added by bladus on 04/13/07 14:34:54.
sfMyDateValidator.class.php (3.5 kB) - added by Arthur.Koziel on 11/02/07 18:34:53.

Change History

04/13/07 14:34:03 changed by bladus

  • attachment sfDateValidator.patch added.

04/13/07 14:34:54 changed by bladus

  • attachment dateTest.php added.

07/10/07 21:37:17 changed by Markus.Staab

  • milestone set to 1.0.6.

07/10/07 23:07:39 changed by Andrejs.Verza

There are still problems with the sfDateValidator not accepting input_date_tag's generated multiple html selects. (#1911)

And here is the patch:

  protected function getValidDate($value, $culture)
  {
    if (is_array ($value))
    {
      $d = @$value ['day'];
      $m = @$value ['month'];
      $y = @$value ['year'];
    }
    else
    {
      // Use the language culture date format
      $result = $this->getContext()->getI18N()->getDateForCulture($value, $culture);
      if ($result === null)
      {
        return null;
      }

      list($d, $m, $y) = $result;
    }

    // Make sure the date is a valid gregorian calendar date also
    if (!checkdate($m, $d, $y))
    {
      return null;
    }

    return strtotime("$y-$m-$d 00:00");
  }

07/31/07 10:47:28 changed by fabien

  • milestone deleted.

11/02/07 18:34:31 changed by Arthur.Koziel

  • qualification set to Unreviewed.

Fabio just send me an email with further improvements to the sfDateValidator:

"I added some code to handle i18N date coming from input_date_tag and object_input_date_tag helpers."

Is this sfDateValidator getting into 1.1 or are you guys working on a completely new version?

11/02/07 18:34:53 changed by Arthur.Koziel

  • attachment sfMyDateValidator.class.php added.

12/09/07 09:24:13 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 1.1.0.

This helper is deprecated in symfony 1.1 and no new feature will be introduced in symfony 1.0. So, this won't be fixed. symfony 1.1 provides much better date and time validators.