{"id":21556928,"url":"https://github.com/muhammadsiyab/php-form-validation-library","last_synced_at":"2025-04-10T10:22:10.795Z","repository":{"id":57021804,"uuid":"145270464","full_name":"MUHAMMADSiyab/PHP-Form-Validation-Library","owner":"MUHAMMADSiyab","description":"Performs Server-Side validation of HTML Forms","archived":false,"fork":false,"pushed_at":"2024-03-25T20:37:16.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-24T09:11:28.103Z","etag":null,"topics":["form-validation","html-forms","php"],"latest_commit_sha":null,"homepage":null,"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/MUHAMMADSiyab.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-19T03:36:58.000Z","updated_at":"2024-03-25T20:37:19.000Z","dependencies_parsed_at":"2024-11-24T10:03:05.707Z","dependency_job_id":null,"html_url":"https://github.com/MUHAMMADSiyab/PHP-Form-Validation-Library","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":0.3846153846153846,"last_synced_commit":"8c6ae65ef1feb8cfdd362fc156bb32b4e23965b7"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUHAMMADSiyab%2FPHP-Form-Validation-Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUHAMMADSiyab%2FPHP-Form-Validation-Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUHAMMADSiyab%2FPHP-Form-Validation-Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUHAMMADSiyab%2FPHP-Form-Validation-Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MUHAMMADSiyab","download_url":"https://codeload.github.com/MUHAMMADSiyab/PHP-Form-Validation-Library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199080,"owners_count":21063641,"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":["form-validation","html-forms","php"],"created_at":"2024-11-24T08:10:21.888Z","updated_at":"2025-04-10T10:22:10.773Z","avatar_url":"https://github.com/MUHAMMADSiyab.png","language":"PHP","readme":"# PHP Form Validation Library \nPerforms Server-Side validation of HTML Forms\n\n## Downloading and implementation \n- Download the zip file manually and include in your project directory \u003cbr /\u003e\n  **OR** (Using Composer) \u003cbr /\u003e\n  run command `composer require muhammadsiyab/form_validation` \n- Include Form_Validation library \n    ```php\n    require_once './vendor/autoload.php'; \n    ```\n\n### Validating form \n```php \n\u003c?php\n\n// Instantiate `Form_Validation` Class\n$form_validation = new \\FormValidation\\Form_Validation();\n\n\n// Array containing custom messages \n// (Optional parameter, if not passed, default error messages will be used)\n\n$messages = array(\n    'required' =\u003e '{field} is cumpolsary',\n    'max_length' =\u003e '{field} must be in limit of {limit}',\n    'min_length' =\u003e '{field} must be at least of {limit} characters',\n    'regex' =\u003e '{field} must be in specific pattern'\n);\n\n\n// Validation rules\n$form_validation-\u003evalidate(array('field_name', 'field_label', 'required|\u003e10|\u003c3', $messages));\n\n\n// Check whether a record exists in database\n$form_validation-\u003eexists('field_name|field_label', 'localhost|user|password|db_name', 'table_name|column_name', 'custom_error');\n\n\n// Check\nif ($form_validation-\u003eis_form_ok() === false) {\n    \n    // Custom error markup\n    $form_validation-\u003eset_error_markup('\u003cli\u003e', '\u003c/li\u003e');\n    \n    // Showing validation errors\n    $errors = $form_validation-\u003eshow_validation_errors();\n    \n    for ($i = 0; $i \u003c count($errors); $i++) {\n\n        echo $errors[$i];\n        \n    }\n    \n} else {\n        \n        // Do something here\n    \n}\n\n```\n\n## Available methods\n#### 1. validate\nValidates the form using specified rules \n###### Parameters:\n* ``array`` **$config** \nArray that contains validation configuration\n   ###### Example\n   `` array('field_name', 'field_label', 'validation_rules_separated_with_pipe', array_containing_custom_messages) ``\n\n#### 2. exists\nChecks whether a value already exists in database \n###### Parameters:\n* ``string`` **$field**\n   Data related with field e.g name \u0026 label\n   ###### Example\n   `` 'field_name|field_label' ``\n\n* ``string`` **$db** \n   Database connection details e.g host, user, password \u0026 database name\n   ###### Example\n   `` 'localhost|user|password|db_name' ``\n\n* ``string`` **$table** \n   Data related with table e.g table name \u0026 column name\n   ###### Example\n   `` 'table_name|column_name' ``\n\n* ``string`` **$error** (Optional)\n   Custom error to show \n\n#### 3. set_error_markup\nSets custom markup for validation errors\n\n* ``string`` **$opening_markup** \n   String containing opening markup\n   ###### Example\n   `` '\u003cspan style=\"color: red\"\u003e' ``\n\n* ``string`` **$closing_markup** \n   String containing closing markup\n   ###### Example\n   `` '\u003c/span\u003e' ``\n\n#### 4. show_validation_errors \n###### @return type ``Array`` (Use for loop to iterate through errors)\nShows validation errors \n\n#### 5. is_form_ok\nChecks whether validation is done with errors or not\n\n## Available validation rules\n| Rule               | Description                        | Syntax                 |\n| :----------------: | :--------------------------------: | :--------------------: |\n| *required*           | Checks if a field is empty         | `required`               |\n| *numeric*           | Checks if a field is not a number         | `numeric`               |\n| *email*           | Checks if email is invalid          | `email`               |\n| *url*           | Checks if url is invalid          | `url`               |\n| *ip*           | Checks if IP address is invalid          | `ip`               |\n| *min_length*           | Sets the minimum length of field          | `\u003c6`               |\n| *max_length*           | Sets the maximum length of field          | `\u003e10`               |\n| *regex*           | Performs regular expression for the field         | `matches/^[a-zA-Z0-9]/`               |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammadsiyab%2Fphp-form-validation-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhammadsiyab%2Fphp-form-validation-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammadsiyab%2Fphp-form-validation-library/lists"}