{"id":26964420,"url":"https://github.com/nicklayb/validizerjs","last_synced_at":"2025-04-03T06:32:17.677Z","repository":{"id":57390443,"uuid":"64247992","full_name":"nicklayb/validizerjs","owner":"nicklayb","description":"A simple html helper for javascript validations","archived":false,"fork":false,"pushed_at":"2016-07-27T00:29:17.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-15T17:07:22.431Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/nicklayb.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":"2016-07-26T19:19:20.000Z","updated_at":"2016-07-26T19:58:57.000Z","dependencies_parsed_at":"2022-09-26T16:51:18.140Z","dependency_job_id":null,"html_url":"https://github.com/nicklayb/validizerjs","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/nicklayb%2Fvalidizerjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fvalidizerjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fvalidizerjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicklayb%2Fvalidizerjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicklayb","download_url":"https://codeload.github.com/nicklayb/validizerjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246948008,"owners_count":20859362,"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":[],"created_at":"2025-04-03T06:31:24.363Z","updated_at":"2025-04-03T06:32:17.669Z","avatar_url":"https://github.com/nicklayb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validizer\n###### By Nicolas Boisvert :: nicklay@me.com\n### A simple html helper for javascript validations\n\nThis is a simple Jquery plugin allowing anyone to easily validate a form within some validations. Of course, the plugin already includes some basic validator such as `required`, `gt` (for greater than), `between` etc... But you fool can add your own validator easily.\n\n## Requirements\n- Jquery v. 2+\n\n\n## Installation\n\n#### npm\n Just execute `npm install validizerjs` in your terminal\n\n#### Downloading\n- Download, as you wish, the minified version or the production version in the repository\n\n## Usage\n\nNow you may wonder: \"How the hell do I use that?\"... Well... It's easier than you can think. If you ever worked with the awesomely wonderful Taylor Otwell's Laravel, you will recognize the valiator syntax (It's pretty inspired from).\n\n##### Making an input validable and defining his rules\nYou need to add the `validable` class to your HTML inputs. You also need the attribute `data-validate` to your element with your rules seperated by a pipe `|`. If the rule requires parameters, you need to add them after a colon `:` and seperate your arguments with comma `,`.\n```html\n\u003cinput type=\"text\" name=\"firstname\" class=\"validable\" data-validate=\"required|len_gte:5\"\u003e\n```\n\nIn our example, my `firstname` input is `required`. So, as long as the field will be empty, the surrounding form will not be submittable. We also included the rule `len_gte` which is length greater than equals with a first parameter of 5. So, as long as the field will be empty **OR** the field will contain a word less than 5 caracter, the surrounding form won't be submittable.\n\n###### What's going on?\n\nAt first, if the field's rules are matched to true, the input will get the class `valid`. If any of the rule is matched to false, the input will get the class `invalid`. On each input change, the surrounding form is validated. If the form contains at least one invalid field, the submit button will be disabled to prevent user from submitting.\n\n### API\n\nSince Validizer is a Jquery plugin, we extended Jquery.\n\nHere are the methods.\n\n`$('input').validate()` : will validate the input's rules.\n\n`$('form').validateAll()` : will validate each `.validable` inputs in the form\n\n### Extending rules\n\nIf you would like to add a custome rules, feel free to do it. Validators are function who are given the input value as `value`, an array of arguments which are the values after the colon as `args` and the context which the input himself. Your validator must return a boolean value\n```js\n$.validators.rules['not_equals'] = function(value, args, context){\n    return (value != args[0]);\n}\n```\nYou could use this rules with a parameter of a string. If your input value is the one given in parameter, let's return true! See the example below.\n```html\n\u003cinput type=\"text\" name=\"firstname\" class=\"validable\" data-validate=\"not_equals:You shall not pass\"\u003e\n```\n\nAs long as your input is not \"You shall not pass\", you validator should pass.\n\n### Built-in rules\n- `required` :\n - Params : no\n - Does : Validate that the field is not empty, in the case of a `radio`, it ensure that at least one option is selected\n- `len_gt` :\n - Params : `:x`, where x is a number\n - Does : Validate if the string length is greater than the x value.\n- `len_gte` :\n - Params : `:x`, where x is a number\n - Does : Validate if the string length is greater than or equals the x value.\n- `len_lt` :\n - Params : `:x`, where x is a number\n - Does : Validate if the string length is less than the x value.\n- `len_lte` :\n - Params : `:x`, where x is a number\n - Does : Validate if the string length is less than or equals the x value.\n- `gt` :\n - Params : `:x`, where x is a number\n - Does : Validate if the input value is greater than the x value.\n- `gte` :\n - Params : `:x`, where x is a number\n - Does : Validate if the input value is greater than or equals the x value.\n- `lt` :\n - Params : `:x`, where x is a number\n - Does : Validate if the input value is less than the x value.\n- `lte` :\n - Params : `:x`, where x is a number\n - Does : Validate if the input value is less than or equals the x value.\n- `between_exclusive` :\n - Params : `:x,y`, where x and y are numbers\n - Does : Validate if the input value is between the x and y values **but not equals**\n- `between` :\n - Params : `:x,y`, where x and y are numbers\n - Does : Validate if the input value is between or equals the x and y values\n- `equals` :\n - Params : `:x`, where x is a string\n - Does : Validate if the input value is exactly the same as x\n- `checked` :\n - Params : no\n - Does : Validate if the input is `checked`. Would only work with `radio` or `checkbox`\n- `date` :\n - Params : no\n - Does : Validate if the input a valid date string according to `Date.parse(x)`\n- `number` :\n - Params : no\n - Does : Validate if the input a valid number according to `isNumeric(x)`\n\n### Conclusion\nIf you're like me and hate doing if...else if...else etc... You may love to use this. Feel free to report problem or suggest anything\n\nEnding joke :\n\u003e **Q** : How many programmers does it takes to change a light bulb? **A** : None, it's a hardware problem\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicklayb%2Fvalidizerjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicklayb%2Fvalidizerjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicklayb%2Fvalidizerjs/lists"}