-1

I want to use validation of model properties in extbase via regex and using the following syntax:

/**
 *
 *@var string $telephone
 *@validate RegularExpression('/^[0-9]+$/')
 */
 $protected $telephone;

But I keep getting a validation error, irrespective of the value of $telephone variable.What am I doing wrong?

user1107888
  • 1,481
  • 5
  • 34
  • 55

1 Answers1

2

You could simply do something like

/**
 *
 * @var string $telephone
 *
 */
 $protected $telephone;

in this case you only get integer values to var telephone.

the other way is to add the right validation syntax

@validate $telephone notEmpty, regularExpression(regularExpression="/^[0-9]+$/")
freshp
  • 525
  • 5
  • 20
  • 2
    If the phone number starts with zero (e.g. `00498912345`), this would end up with `498912345` as integer representation. Find more details here https://docs.typo3.org/typo3cms/ExtbaseFluidBook/9-CrosscuttingConcerns/2-validating-domain-objects.html – Oliver Hader Oct 12 '16 at 11:06