How do I set the model’s validator so that it will accept input between two number representing latitude, 0 and 90? You cannot have latitude greater than 90 (North Pole).
For example, if user inputs latitude of 114 degrees by mistake, the input will be invalid.
The coordinates are floats, of arbitrary decimal points, eg 89.34632882
array('latitude', 'in','range'=>/* what to put here? */),
range seems to be supposed to be an array with a list of accepted values, ie ‘range’=array(1,2,3). I wish I could do a ‘max=>90’ and ‘min’=>0 somehow, but this is defined for string length rather than numerical values.
array('latitude', 'in', 'max'=90, 'min'=>0), //this is wrong of course
Eh, never mind. I solved it, not with “range” but with “compare” which I didn’t expect…
array('latitude', 'compare','operator'=>'<=','compareValue'=>90, 'message'=>'maximum is 90 which is North Pole' ),
array('latitude', 'compare','operator'=>'>=','compareValue'=>0 ),