Question

How can I extend the following zend validator to include numbers with commas and points separator. Eg: 1.234.567,89

return array(
    "*" => array("allowEmpty" => true),
    "pret"  => array(
                  "digits", 
                  "presence" => "required"
               ),
    );
Was it helpful?

Solution

You can add this validator in your InputFilter function:

array(
   'name' => 'Regex',
   'options' => array(
          'pattern' => '/^[0-9_\.\,]*$/',
          'messages' => array(
                 \Zend\Validator\Regex::INVALID  => 'Your error message.',
      ),
     ),
),

And you can add your character need to be accept for your input in the patterns(Regular Expression).

I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top