Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel regex validation not working

I've just started using laravel and I'm working on validating a textarea in one of my forms.

The textarea is for the users bio and so I only want to allow letters, numbers, spaces and the following characters: , . ? ; : ' " - () ! / @ $

This is what I have

$validator = Validator::make(Input::all(),
array('bio' => array('regex:[a-zA-Z0-9 ,\.\?;:\'"-\(\)!/@\$]')
    )
);

I've been searching and trying a lot to get it to work but I just can't figure it out.

Any help would be much appreciated.

Thanks

like image 287
Scott Avatar asked Mar 15 '14 22:03

Scott


1 Answers

Try this:

array('Regex:/^[A-Za-z0-9\-! ,\'\"\/@\.:\(\)]+$/')
like image 130
enga Avatar answered Oct 03 '22 07:10

enga