0

The user enters his/her business name. Every this is allowed except special characters. Instead of a white list I would want to main a blacklist. Here's my piece of code

'nameofbusiness' => v::not (
                            v::oneOf ( 
                                                v::contains( '~'), v::contains ( '+' ), 
                                                v::contains( '-' ),v::contains ( '!' ), 
                                                v::contains( '@' ),v::contains ( '$' ), 
                                                v::contains ( '%' ), v::contains ( '^' ), 
                                                v::contains ( '&' ), v::contains ( '*' ), 
                                                v::contains ( '(' ), v::contains ( ')' ), 
                                                v::contains ( '[' ), v::contains ( ']' ), 
                                                v::contains ( '=' ), v::contains ( '_' ), 
                                                v::contains ( '/' ), v::contains ( '?' ), 
                                                v::contains ( '>' ), v::contains ( '<' ), 
                                                v::contains ( '.' ), v::contains ( ',' ), 
                                                v::contains ( ':' ), v::contains ( ';' ), 
                                                v::contains ( '"' ) 
                                       )
                            )

+(plus) #(hash) and &(ampersand) are slipping through these gates. How can i make sure that they don't? Any help would be very much appreciated.

Davide Pastore
  • 8,678
  • 10
  • 39
  • 53
Indark
  • 322
  • 1
  • 2
  • 14
  • I'm not really sure what you're expecting here. Can you please add some cases and the related excepted validation results? Thanks. – Davide Pastore Jun 23 '18 at 15:06
  • Hello Davide, The field "nameof business" should not contain any of the characters that I have indicated. If the field "nameofbusiness" happens to contain either a +(plus) or a #(hash) or a &(ampersand) -- the validation is skipped. Ideally it should throw back and error - but that is not the case.. Hope this clarification helps – Indark Jun 25 '18 at 06:36
  • Hi Indark. It does work on my PC using respect/validation v.1.1.22. The only thing that I've found is that you're missing the # (hash) character validation. – Davide Pastore Aug 11 '18 at 17:19
  • I'm using "davidepastore/slim-validation": "^0.5.0" - Because we are running PHP 5.5. Should I upgrade to 1.1.22? – Indark Aug 29 '18 at 10:23
  • Yes, give it a try. – Davide Pastore Aug 29 '18 at 10:44

0 Answers0