Here is a sample that I use, Its not exactly what your looking for,
but a little tweaking will get you where you need to be:

var $validate = array(
   'expires' =>
array('rule'=>array('date','mdy'),'rule'=>array('validateFutureDate'),'on'=>'create')
);


        function validateFutureDate($value) {
        $valid = false;

        $timestamp = strtotime(str_replace('-','/',
$value['expires']));
                $t = time()+(86400*34);
                if($timestamp >= $t)
                        $valid = true;

        return $valid;
    }

On Sep 16, 3:08 am, RichardAtHome <[EMAIL PROTECTED]> wrote:
> > I was afraid that might be the case
>
> It's really not difficult :-)
>
> And its a very powerful solution once you understand how it works.
>
> On Sep 16, 1:46 am, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > Thanks. I was afraid that might be the case.
>
> > On Sep 15, 7:42 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
>
> > > You can't use functions i.e date() at class definitions, create a
> > > custom method in the model and use that as a validation rule.
>
> > > On Mon, Sep 15, 2008 at 9:34 PM, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > > > According to the documentation that's the proper way to define the
> > > > array.
>
> > > >http://book.cakephp.org/view/139/comparison
>
> > > > It just amounts to defining an array without defining the keys if I'm
> > > > not mistaken. I'll take a closer look at the syntax in the morning
> > > > when my mind is a little fresher. I'll post something here if
> > > > something jumps out at me.
>
> > > > On Sep 15, 4:20 pm, 703designs <[EMAIL PROTECTED]> wrote:
> > > >> I noticed that the way you coded your array would definitely throw a
> > > >> syntax error.
>
> > > >> How about
> > > >> 'rule' => array(
> > > >>     'comparison' => date()
> > > >> ),
>
> > > >> I'll try this on my Cake installation later to check, as I haven't
> > > >> used the 'comparison' validator. I just know that your array looks
> > > >> botched.
>
> > > >> On Sep 15, 5:14 pm, 703designs <[EMAIL PROTECTED]> wrote:
>
> > > >> > date() should just return the formatted date string. What sort of
> > > >> > errors are you seeing?
>
> > > >> > On Sep 15, 3:51 pm, Tony Thomas <[EMAIL PROTECTED]> wrote:
>
> > > >> > > Anyone have a proven method for validating submitted dates to make
> > > >> > > sure they're not in the future?
>
> > > >> > > The closest I can get is:
>
> > > >> > > 'date_field' => array('rule' => array('comparison',
> > > >> > >                                                         '>=',
> > > >> > >                                                         date()),
> > > >> > >                                                         'message' 
> > > >> > > => 'Dates cannot be in the future.')
>
> > > >> > > But date() is throwing a syntax error.
>
> > > >> > > None of the core time testing helpers do this.
>
> > > >> > > I should note that in the controller, before save, the date string 
> > > >> > > is
> > > >> > > converted into a Unix timestamp.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to