How to validate a Mask TextInput?

Currently using this:

TextInput::make('mobile_phone')
  ->label('Mobile Phone')
  ->required()
  ->mask(fn (Mask $mask) => $mask->pattern('(000) 000-0000'))
  ->tel()
  ->telRegex('/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\.\/0-9]*$/'),


What I want is that if I hit submit, the error should display "The phone number is not valid. Please enter a valid phone number".
Was this page helpful?