{"id":21059110,"url":"https://github.com/ganeshrvel/php-form-validator","last_synced_at":"2025-08-09T23:09:11.163Z","repository":{"id":110981894,"uuid":"121379022","full_name":"ganeshrvel/php-form-validator","owner":"ganeshrvel","description":"Advanced PHP Form Validator","archived":false,"fork":false,"pushed_at":"2019-01-26T06:47:46.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T00:41:32.236Z","etag":null,"topics":["form-validation","php","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ganeshrvel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-13T12:18:42.000Z","updated_at":"2023-04-07T20:22:06.000Z","dependencies_parsed_at":"2023-07-24T14:46:07.137Z","dependency_job_id":null,"html_url":"https://github.com/ganeshrvel/php-form-validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ganeshrvel/php-form-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshrvel%2Fphp-form-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshrvel%2Fphp-form-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshrvel%2Fphp-form-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshrvel%2Fphp-form-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ganeshrvel","download_url":"https://codeload.github.com/ganeshrvel/php-form-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ganeshrvel%2Fphp-form-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269649848,"owners_count":24453541,"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","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","php","wordpress"],"created_at":"2024-11-19T17:09:56.198Z","updated_at":"2025-08-09T23:09:11.139Z","avatar_url":"https://github.com/ganeshrvel.png","language":"PHP","funding_links":["https://paypal.me/ganeshrvel"],"categories":[],"sub_categories":[],"readme":"# PHP Form Validator\n\n- Author: [Ganesh Rathinavel](https://www.linkedin.com/in/ganeshrvel \"Ganesh Rathinavel\")\n- License: [MIT](https://github.com/ganeshrvel/php-form-validator/blob/master/LICENSE \"MIT\")\n- Repo URL: [https://github.com/ganeshrvel/php-form-validator](https://github.com/ganeshrvel/php-form-validator \"https://github.com/ganeshrvel/php-form-validator\")\n- Contacts: ganeshrvel@outlook.com\n- Requirements: PHP 5+\n\n## Usage\n\n```php\n    # import the library file as\n    require_once('form-validator.php');\n```\n\n\n```php\n\t$vObj = new FormValidator();\n\t\n\t$vObj-\u003eset_rules( $options_key_1 );\n\t$vObj-\u003eset_rules( $options_key_2 );\n\t\n\t#Check 'Example' Section for $options\n\t\n\tif ( $vObj-\u003erun() == false ) {\n\t   echo \"error\";\n\t   //dont continue\n\t} else {\n\t   echo \"success\";\n\t   //continue\n\t}\n```\n    \n\n\n----------\n#### Errors:\n\n```php\n    /**\n     * shows all validation errors\n     */\n    echo $vObj-\u003eshow_all_errors();\n    \n    /**\n     * displays single error\n     */\n    echo $vObj-\u003eshow_error();\n    \n    /**\n     * param 1: shows 2 error,\n     * param2: strips all styles,\n     * param3: a 'special character' to seperate multiple errors [Only valid while $strip_styles = true],\n     * param4: display \"developer only\" debugging errors\n     */\n    \n    echo $vObj-\u003eshow_error( 2,\n       true,\n       \"|\",\n       true );\n    \n    /**\n     *show the validation error for a specific field\n     */\n    echo $vObj-\u003eshow_error_item( 'age1' );\n    \n    /**\n     * returns the 'form field name' in case an error occurs\n     */\n    echo $vObj-\u003eerror_field_id;\n    \n```\n----------\n```php\n    /**\n     * @param $param : form input field name\n     * @param bool $trim : trim the output (only for non array (String) inputs)\n     * @param bool $isArray : true if an array value is expected from the form input\n     * @param bool $sql_escape : escape the input value against sql injections\n     *\n     * @return null|string\n     */\n    echo $vObj-\u003epost( 'age1', $trim = false, $isArray = false, $sql_escape = false );\n    echo $vObj-\u003eget( 'age1', $trim = false, $isArray = false, $sql_escape = false );\n    echo $vObj-\u003erequest( 'age1', $trim = false, $isArray = false, $sql_escape = false );\n    echo $vObj-\u003efiles( 'file1', $trim = false, $isArray = false, $sql_escape = false );\n\n```\n----------\n```php\n    /**\n     * pass a custom array value instead of form input parameters; \n     * 'type' won't be valid after $custom_array is set\n     * */\n    \n    $custom_array_validate = array (\n       'key1' =\u003e 'value1',\n       'key2' =\u003e 'value2',\n    );\n    $vObj = new FormValidator( $custom_array_validate );\n\n```\n----------\n\n#### Example:\n```php\n    $vObj-\u003eset_rules( array (\n       'name'                  =\u003e 'age1', //HTML form 'field name'; allow_array supported\n       'placeholder'           =\u003e 'Age 1', //used for displaying errors; allow_array supported\n       'type'                  =\u003e 'post', //FORM method; allow_array supported\n       'required'              =\u003e true, //allow_array supported\n       'allow_array'           =\u003e true, //allow_array: true -\u003e Both Array and String values from the form field are allowed, allow_array: false -\u003e Only String is allowed\n       'is_array'              =\u003e true, //is_array: true -\u003e Only array values are expected from the form field ; allow_array supported;\n       'trim'                  =\u003e true, //allow_array supported\n       'matches'               =\u003e array ( 'The matching placeholder', $vObj-\u003eget( 'name2' ) ), //allow_array supported\n       'differs'               =\u003e array ( 'The differing placeholder', $vObj-\u003eget( 'name3' ) ), //allow_array supported\n       'is_duplicate'          =\u003e array (\n          'table_name'        =\u003e 'pdg_user_info',//wordpress support available; wordpress db table name\n          'column_name'       =\u003e 'mobile_no',\n          'primary_key'       =\u003e 'personal_info_id',\n          'primary_key_value' =\u003e 3608,\n       ),\n       'is_unique'             =\u003e array ( 'wp_wordpress_user', 'email' ), //wordpress support available; allow_array supported\n       'custom_error'          =\u003e \"Some custom error message\", //allow_array supported\n       'min_length'            =\u003e 2, //allow_array supported\n       'max_length'            =\u003e 5, //allow_array supported\n       'exact_length'          =\u003e 4, //allow_array supported\n       'greater_than'          =\u003e 1254,\n       'greater_than_equal_to' =\u003e 1254,\n       'less_than'             =\u003e 1245,\n       'less_than_equal_to'    =\u003e 1245,\n       'max_item_limit'        =\u003e 5, //Only supported when the form field value is an array\n       'min_item_limit'        =\u003e 3, //Only supported when the form field value is an array\n       'exact_item_limit'      =\u003e 4, //Only supported when the form field value is an array\n       'unique_items'          =\u003e true, //Checks whether there are any duplicated values inside the inputted array; Only supported when the form field value is an array\n       'in_list'               =\u003e array ( \"1\" =\u003e \"First year\", 2 =\u003e \"Second year\", 3 =\u003e \"Third year\" ), //check whether any of these values exists; an associative or sequential array supported; allow_array supported;\n       'alpha'                 =\u003e true,\n       'alpha_space'           =\u003e true,\n       'alpha_numeric'         =\u003e true,\n       'alpha_numeric_spaces'  =\u003e true,\n       'alpha_dash'            =\u003e true,\n       'alpha_numeric_dash'    =\u003e true,\n       'alpha_dot'             =\u003e true,\n       'alpha_numeric_dot'     =\u003e true,\n       'integer'               =\u003e true,\n       'numeric'               =\u003e true, //allow_array supported\n       'decimal'               =\u003e true,\n       'allow_special_chars'   =\u003e false,\n       'allow_space'           =\u003e false,\n       'allow_alpha'           =\u003e false,\n       'allow_number'          =\u003e false,\n       'valid_url'             =\u003e true, //allow_array supported\n       'valid_email'           =\u003e true, //allow_array supported\n       'valid_phone'           =\u003e true, //allow_array supported\n       'valid_date'            =\u003e true,\n       'date_range'            =\u003e array ( 'min' =\u003e '2009-06-17', 'max' =\u003e '2009-09-05' ),\n       'valid_ip'              =\u003e true,\n       'sql_escape'            =\u003e true, //allow_array supported\n       'sanitize_input'        =\u003e true, //allow_array supported\n       'file_extension'        =\u003e array ( 'jpg', 'jpeg', 'png', 'bmp' ), //only supported by files type\n       'file_max_size'         =\u003e 1000000, //only supported by the 'files' type; in bytes 1000000 = 1 MB\n    ) );\n    \n    $vObj-\u003eset_rules( array (\n       'name'                  =\u003e 'age2',\n       'placeholder'           =\u003e 'Age 2',\n       'type'                  =\u003e 'get',\n       'required'              =\u003e true,\n       'trim'                  =\u003e true,\n       'allow_array'           =\u003e false,\n       'matches'               =\u003e array ( 'Age 1', $vObj-\u003eget( 'age1' ) ),\n       'differs'               =\u003e array ( 'Age 3', $vObj-\u003eget( 'age3' ) ),\n       'is_unique'             =\u003e array ( 'wp_wordpress_user', 'email' ), //wordpress support available; wordpress db table name\n       'min_length'            =\u003e 2,\n       'max_length'            =\u003e 5,\n       'exact_length'          =\u003e 4,\n       'greater_than'          =\u003e 1254,\n       'greater_than_equal_to' =\u003e 1254,\n       'less_than'             =\u003e 1245,\n       'less_than_equal_to'    =\u003e 1245,\n       'in_list'               =\u003e array ( 111, 222, 333 ),\n       'alpha'                 =\u003e true,\n       'alpha_space'           =\u003e true,\n       'alpha_numeric_spaces'  =\u003e true,\n       'alpha_numeric'         =\u003e true,\n       'alpha_dash'            =\u003e true,\n       'alpha_numeric_dash'    =\u003e true,\n       'alpha_dot'             =\u003e true,\n       'alpha_numeric_dot'     =\u003e true,\n       'integer'               =\u003e true,\n       'numeric'               =\u003e true,\n       'decimal'               =\u003e true,\n       'allow_special_chars'   =\u003e false,\n       'allow_space'           =\u003e false,\n       'allow_alpha'           =\u003e false,\n       'allow_number'          =\u003e false,\n       'valid_url'             =\u003e true,\n       'valid_email'           =\u003e true,\n       'valid_phone'           =\u003e true,\n       'valid_date'            =\u003e true,\n       'date_range'            =\u003e array ( 'min' =\u003e '2009-06-17', 'max' =\u003e '2009-09-05' ),\n       'valid_ip'              =\u003e true,\n       'sql_escape'            =\u003e true,\n    ) );\n\n```\n\n ### Contribute\n- Fork the repo and create your branch from master.\n- Update the documentation if needed.\n- Issue a pull request!\n\nWhen you submit code changes, your submissions are understood to be under the same [MIT License](https://github.com/ganeshrvel/php-form-validator/blob/master/LICENSE \"MIT License\") that covers the project. Feel free to contact the maintainers if that's a concern.\n\n\n### Buy me a coffee\nHelp me keep the app FREE and open for all.\nPaypal me: [paypal.me/ganeshrvel](https://paypal.me/ganeshrvel \"paypal.me/ganeshrvel\")\n\n### Contacts\nPlease feel free to contact me at ganeshrvel@outlook.com\n\n### License\nelectron-react-redux-advanced-boilerplate | Electron-React-Redux Advanced Boilerplate is released under [MIT License](https://github.com/ganeshrvel/php-form-validator/blob/master/LICENSE \"MIT License\").\n\nCopyright © 2018-Present Ganesh Rathinavel\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganeshrvel%2Fphp-form-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fganeshrvel%2Fphp-form-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fganeshrvel%2Fphp-form-validator/lists"}