cphalcon: Regex validation pattern doesn't work after upgrade to 3
Expected and Actual Behavior
The following Regex validator pattern worked fine before I upgraded to version 3:
'pattern' => '/(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)/'
Also the new date validator doesn’t produce an error message 'format' => 'd.m.Y'.
Example
/*
* Duration
*/
$duration = new Text("duration", array(
'class' => 'form-control',
'id' => 'duration'
));
$duration->setLabel('Dauer');
$duration->setAttribute('autocomplete', 'off');
$duration->addValidator(new Regex(array(
'pattern' => '/(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)/',
'message' => 'Falsche oder fehlende Dauer.'
)
));
$this->add($duration);
Details
- Phalcon version: 3
- PHP Version: 5.6
- Operating System: Ubuntu
- Server: Apache
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (12 by maintainers)
Just change their code to return actual values, not changed and use afterFetch/afterSave if you need formatted values.
Or remove them totally because i don’t know why you need getters/setters with public properties, just decide - protected properties and getters - or public properties and no getters. there is no point in having both public.
What you mean before 3 ? Code in 2.1.x is exactly the same. In 2.0.x it’s diffrent and validation is done on data form, not on model - https://github.com/phalcon/cphalcon/blob/2.0.x/phalcon/validation.zep#L77. That’s why it was working. Now it isn’t beacause your getters returns correct values which are passing validation. The same will happen however if you will even use
validation()in model. Just wrong php code.Looks like working for me. Phalcon 3.0.0.
Without message in date validator i have
Field duration is not a valid dateas well.