<?php
class Model_Client extends Orm\Model {
protected static $_properties = array(
'id',
'created_at',
'updated_at',
'given_names' => array(
'type' => 'string',
'label' => 'Given Names',
'validation' => array('trim','strip_tags','required'),
),
'surname' => array(
'type' => 'string',
'label' => 'Surname',
'validation' => array('trim','strip_tags','required', 'valid_string'=>array('alpha','spaces')),
),
'birthdate',
'birthcountry'
);
protected static $_observers = array(
'Orm\Observer_CreatedAt' => array('before_insert'),
'Orm\Observer_UpdatedAt' => array('before_save'),
'Orm\Observer_Validation' => array('before_save'),
);
}
Unfortunately, the validation for the surname field *always* fails, as soon as I put anything else in the 'valid_string' array, apart from 'alpha'. It works like this:
(1) Using array('alpha') only: works as expected
(2) Using array('alpha', *): if anything else is added after 'alpha' (such as 'spaces', or 'dashes'), then it ignores whatever is added afterwards, and validation only works if there are only alpha characters - that is, if I add a space (or a dash), even if I specified that this is be allowed by using 'spaces' (or 'dashes'), then validation fails
(3) Using array(*,'alpha'): if anything is added before 'alpha', then validation *always* fails, even if the field contains only alpha characters.
Is this a bug, or am I doing something obviously stupid? It looks like you're new here. If you want to get involved, click one of these buttons!