{"action":"closed","issue":{"url":"https://api.github.com/repos/siriusphp/validation/issues/17","labels_url":"https://api.github.com/repos/siriusphp/validation/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/siriusphp/validation/issues/17/comments","events_url":"https://api.github.com/repos/siriusphp/validation/issues/17/events","html_url":"https://github.com/siriusphp/validation/issues/17","id":57817956,"number":17,"title":"Validation failing for empty values","user":{"login":"christiaan-lombard","id":6524763,"avatar_url":"https://avatars.githubusercontent.com/u/6524763?v=3","gravatar_id":"","url":"https://api.github.com/users/christiaan-lombard","html_url":"https://github.com/christiaan-lombard","followers_url":"https://api.github.com/users/christiaan-lombard/followers","following_url":"https://api.github.com/users/christiaan-lombard/following{/other_user}","gists_url":"https://api.github.com/users/christiaan-lombard/gists{/gist_id}","starred_url":"https://api.github.com/users/christiaan-lombard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christiaan-lombard/subscriptions","organizations_url":"https://api.github.com/users/christiaan-lombard/orgs","repos_url":"https://api.github.com/users/christiaan-lombard/repos","events_url":"https://api.github.com/users/christiaan-lombard/events{/privacy}","received_events_url":"https://api.github.com/users/christiaan-lombard/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-16T15:34:05Z","updated_at":"2015-02-27T08:13:15Z","closed_at":"2015-02-27T08:13:15Z","body":"Unless I am missing something, most rules should not be validated (or validation should return true) if the input is null or an empty string (except for Required, Length and some others).\r\n\r\nHere is an example where Email, AlphaNumeric, AlphaNumHyphen and Alpha is failing validation, but is not required:\r\n\r\n```PHP\r\n\r\n<?php\r\n\r\nrequire 'vendor/autoload.php';\r\n\r\n$input = [\r\n  'name' => 'Christiaan',\r\n  'email' => '',\r\n  'address' => [\r\n    'line_1' => '',\r\n    'line_2' => '',\r\n    'country' => ''\r\n  ]\r\n\r\n];\r\n\r\n$validator = new Sirius\\Validation\\Validator;\r\n\r\n$validator\r\n  ->add('name', ['Required', 'AlphaNumeric'])\r\n  ->add('email', ['Email'])\r\n  ->add('address[line_1]', ['AlphaNumeric'])\r\n  ->add('address[line_2]', ['AlphaNumHyphen'])\r\n  ->add('address[country]', ['Alpha'])\r\n  ->validate($input);\r\n\r\n?>\r\n\r\n<pre><?php print_r($validator->getMessages()); ?></pre>\r\n\r\n```\r\n\r\nReturns:\r\n\r\n```PHP\r\n\r\nArray\r\n(\r\n    [email] => Array\r\n        (\r\n            [0] => Sirius\\Validation\\ErrorMessage Object\r\n                (\r\n                    [template:protected] => This input must be a valid email address\r\n                    [variables:protected] => Array\r\n                        (\r\n                            [value] => \r\n                        )\r\n\r\n                )\r\n\r\n        )\r\n\r\n    [address[line_1]] => Array\r\n        (\r\n            [0] => Sirius\\Validation\\ErrorMessage Object\r\n                (\r\n                    [template:protected] => This input can contain only letters and digits\r\n                    [variables:protected] => Array\r\n                        (\r\n                            [value] => \r\n                        )\r\n\r\n                )\r\n\r\n        )\r\n\r\n    [address[line_2]] => Array\r\n        (\r\n            [0] => Sirius\\Validation\\ErrorMessage Object\r\n                (\r\n                    [template:protected] => This input can contain only letters, digits, spaces, hyphens and underscores\r\n                    [variables:protected] => Array\r\n                        (\r\n                            [value] => \r\n                        )\r\n\r\n                )\r\n\r\n        )\r\n\r\n    [address[country]] => Array\r\n        (\r\n            [0] => Sirius\\Validation\\ErrorMessage Object\r\n                (\r\n                    [template:protected] => This input can contain only letters\r\n                    [variables:protected] => Array\r\n                        (\r\n                            [value] => \r\n                        )\r\n\r\n                )\r\n\r\n        )\r\n\r\n)\r\n\r\n```\r\n\r\n"}}