{"id":18803083,"url":"https://github.com/nabeelalihashmi/lightvalidator","last_synced_at":"2026-01-05T11:30:16.697Z","repository":{"id":62551051,"uuid":"505361668","full_name":"nabeelalihashmi/LightValidator","owner":"nabeelalihashmi","description":"Lightweight validation library for PHP","archived":false,"fork":false,"pushed_at":"2022-06-23T16:10:46.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T20:22:44.378Z","etag":null,"topics":["php","php-validation","php-validator","validation","validator"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nabeelalihashmi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-20T08:45:15.000Z","updated_at":"2022-06-20T08:47:43.000Z","dependencies_parsed_at":"2022-11-03T02:00:55.787Z","dependency_job_id":null,"html_url":"https://github.com/nabeelalihashmi/LightValidator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FLightValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FLightValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FLightValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FLightValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabeelalihashmi","download_url":"https://codeload.github.com/nabeelalihashmi/LightValidator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239735259,"owners_count":19688262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-validation","php-validator","validation","validator"],"created_at":"2024-11-07T22:33:01.944Z","updated_at":"2026-01-05T11:30:16.653Z","avatar_url":"https://github.com/nabeelalihashmi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![LightValidator](./docs/header.png)\n\n# LightValidator\n\nFast and easy to use validator for PHP. This is esily extensible.\n\n## Features\n\n    * Fast\n    * Easy\n    * Lightweight\n    * Supports custom messages\n\n\n## Installtion\n```\ncomposer require nabeelalihashmi/LightValidator\n```\n\n## Basic Usage\n\nLValidator requirs 3 arguments, the first is array you want to validate, the second is the rules and the third is the overriding messages.\n\nIf overriding messages is not provided, the default messages will be used.\n\n`validate` method returns true if validation is successful and array of errors if validation fails.\n\n```\n\n$valid_ids = [1,3,4];\n\n\n$rules = [\n    'username' =\u003e [\n        'required',\n        'alphanumeric',\n        'min' =\u003e 3,\n        'max' =\u003e 10\n    ],\n\n    'email' =\u003e [\n        'required',\n        'email'\n    ],\n\n    'id' =\u003e [\n        'required',\n        'numeric',\n        'in' =\u003e $valid_ids\n    ]\n];\n\n$overrride_messages = [\n    'id' =\u003e  [ \n        'in' =\u003e ['ID Must have value betweeen ' . implode(', ', $valid_ids)]\n    ],\n    'username' =\u003e [\n        'required' =\u003e 'Username is required',\n        'string' =\u003e 'Username must be string',\n        'min' =\u003e 'Username must be at least 3 characters',\n        'max' =\u003e 'Username must be at most 10 characters',\n    ],\n    'email' =\u003e [\n        'required' =\u003e 'Email is required',\n    ],\n    'password' =\u003e [\n        'required' =\u003e 'Password is required',\n        'min' =\u003e 'Password must be at least 6 characters',\n        'max' =\u003e 'Password must be at most 10 characters',\n    ],\n];\n\n$v = new LValidator($_GET + $_POST, $rules, $overrride_messages);\n$results = $v-\u003evalidate();\n\nvar_dump($results);\n```\n\n## Rules\n\nRules are array. Each rule is an array with key as the field name and value as the rule. The rule can be a string or a key value pair.\n\n```\n'username' =\u003e [\n        'required',\n        'alphanumeric',\n        'min' =\u003e 3,\n        'max' =\u003e 10\n]\n\n```\n\n## Overriding Messages\n\nAn overriding message is an array of messages. The key is the rule name and the value is the message.When a rule fails, the message will be used.\n\n## Available validations in package\n\n* required($key) \n* min($key, $value) \n* max($key, $value) \n* email($key) \n* url($key) \n* integer($key) \n* float($key) \n* boolean($key) \n* alpha($key) \n* alphanumeric($key) \n* numeric($key) \n* regex($key, $value) \n* equal($key, $value) \n* different($key, $value) \n* contains($key, $value) \n* starts_with($key, $value) \n* ends_with($key, $value) \n* length($key, $value) \n* min_length($key, $value) \n* max_length($key, $value) \n* in($key, $value) \n* not_in($key, $value) \n* ip($key) \n* mac_address($key) \n* date_format($key, $value) \n* boolean_string($key) \n* is_valid_person_name($key) \n* is_valid_person_name_with_space($key) \n* date_between($key, $value) \n\n## Extending\n\nYou can add your own rules by adding rule handler. A rule handler is a funcion with two arguments, the first is the key and the second is the value. The function should return true if the value is valid and false if the value is invalid. The second argument is the optional.\n\n```\npublic function islessthan10($key) {\n    return intval($key) \u003c 10;\n}\n```\npublic function islessthanVal($key, $val) {\n    return intval($key) \u003c intval($val);\n}\n\n```\n\n------\n\n## License\n\nLightValidator is released under permissive licese with following conditions:\n\n* It cannot be used to create adult apps.\n* It cannot be used to gambling apps.\n* It cannot be used to create apps having hate speech.\n\n### MIT License\n\nCopyright 2022 Nabeel Ali | IconicCodes.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeelalihashmi%2Flightvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabeelalihashmi%2Flightvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeelalihashmi%2Flightvalidator/lists"}