How can I create a validation rule that allows a field to be empty but if it is not, it needs to be numeric and 4 character long?
This is what I have now
'year' => array(
'numeric' => array(
'rule' => 'numeric',
'message' => 'Numbers only'
),
'maxLength' => array(
'rule' => array('maxLength', 4),
'message' => 'Year in YYYY format'
),
'minLength' => array(
'rule' => array('minLength', 4),
'message' => 'Year in YYYY format'
)
)
That works great but when the field is empty, it still run the validation.
Thanks,
Tee