Re: validate as hour

2009-11-30 Thread LunarDraco
This regular Expression will force a number between 0-23 Raw Reg ex: ^1?[0-9]{1}$|^2[0-3]{1}$ I'm remembering for php some of these char in the regex provided need to be escaped. Formated for PHP: /^1?[0-9]{1}$|^2[0-3]{1}$/ And here is a good on line real time tester for regular expressions: htt

Re: validate as hour

2009-11-29 Thread Indemnity83
I would just create a custom validation function: /** * function intRange * * Checks if a value is an integer within the * range given (inclusive) * * @param $value to be checked * @param $start of range * @param $end of range * @return bool */ function intRange($value,$start,$end) {

Re: validate as hour

2009-11-28 Thread Dave
err... never mind... doesn't help with decimals On Sat, Nov 28, 2009 at 1:35 PM, Dave wrote: > He can then add the "numeric" rule as well > > > On Fri, Nov 27, 2009 at 9:30 AM, r4zv4n wrote: > >> 'range' still won't fit his purpose, as it will allow for non-integer >> values ;) >> >> On Nov 27,

Re: validate as hour

2009-11-28 Thread Dave
He can then add the "numeric" rule as well On Fri, Nov 27, 2009 at 9:30 AM, r4zv4n wrote: > 'range' still won't fit his purpose, as it will allow for non-integer > values ;) > > On Nov 27, 8:54 am, jburns wrote: > > Ah - yes - good call. It was late...! > > > > I should have said 'rule' => arra

Re: validate as hour

2009-11-27 Thread r4zv4n
'range' still won't fit his purpose, as it will allow for non-integer values ;) On Nov 27, 8:54 am, jburns wrote: > Ah - yes - good call. It was late...! > > I should have said 'rule' => array('range', -1, 24). > > I agree with you that the best way is to present a drop down list as > that precis

Re: validate as hour

2009-11-26 Thread jburns
Ah - yes - good call. It was late...! I should have said 'rule' => array('range', -1, 24). I agree with you that the best way is to present a drop down list as that precisely controls the available inputs. On Nov 27, 6:39 am, r4zv4n wrote: > 'between' actually means that the data's length shoul

Re: validate as hour

2009-11-26 Thread r4zv4n
'between' actually means that the data's length should be between those numbers (i.e. between 0 and 23 characters), so that won't work. One easy solution would be to use 'inList', like this: 'rule' => array ('inList', array(0,1,2,3,..,23)) I'm assuming that on the client side, you're actually

Re: validate as hour

2009-11-26 Thread jburns
I think you'd have to add two rules which, when combined, only accepts the data you want. A custom rule should do it too - I'll have a go tomorrow if this is still open. In the meantime, try this: http://book.cakephp.org/view/246/decimal ...but with a 0 for the number of decimal places. Don't kno

Re: validate as hour

2009-11-26 Thread ge...@dinnerbooking.com
Kind of. But this also allows "0.01" How would I allow only 0, 1 ...23 and NOT numbers like 0.01 On Nov 26, 7:48 pm, jburns wrote: > array('rule' => array('between', 0, 23), >         'message' => 'Please enter a number between 0 and 23.') > > On Nov 26, 6:41 pm, "ge...@dinnerbooking.com" > > w

Re: validate as hour

2009-11-26 Thread jburns
array('rule' => array('between', 0, 23), 'message' => 'Please enter a number between 0 and 23.') On Nov 26, 6:41 pm, "ge...@dinnerbooking.com" wrote: > I have an field which is an hour: > > "hour" => array( >         "required" => true, >         "allowEmpty" => false, >         "rule" =>