{"id":17473870,"url":"https://github.com/gocanto/easiest-js-validator","last_synced_at":"2025-04-16T04:45:53.597Z","repository":{"id":44930482,"uuid":"62407362","full_name":"gocanto/easiest-js-validator","owner":"gocanto","description":"The easiest way to validate your forms without 3rd party packages","archived":false,"fork":false,"pushed_at":"2023-02-10T02:29:13.000Z","size":505,"stargazers_count":54,"open_issues_count":1,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-18T20:46:52.457Z","etag":null,"topics":["javascript","validator"],"latest_commit_sha":null,"homepage":"https://gocanto.github.io/easiest-js-validator","language":"JavaScript","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/gocanto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-07-01T16:53:50.000Z","updated_at":"2023-09-08T17:12:11.000Z","dependencies_parsed_at":"2024-11-01T13:03:58.118Z","dependency_job_id":"fa870a13-4031-4e40-abda-a6e87523dffd","html_url":"https://github.com/gocanto/easiest-js-validator","commit_stats":{"total_commits":48,"total_committers":4,"mean_commits":12.0,"dds":0.625,"last_synced_commit":"d67dd3f37177ac2d3245ebcc89457a88ae65e80e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocanto%2Feasiest-js-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocanto%2Feasiest-js-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocanto%2Feasiest-js-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocanto%2Feasiest-js-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gocanto","download_url":"https://codeload.github.com/gocanto/easiest-js-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249197819,"owners_count":21228641,"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":["javascript","validator"],"created_at":"2024-10-18T18:07:31.650Z","updated_at":"2025-04-16T04:45:53.560Z","avatar_url":"https://github.com/gocanto.png","language":"JavaScript","funding_links":[],"categories":["Awesome Vue.js [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)","Awesome Vue.js"],"sub_categories":["Libraries \u0026 Plugins"],"readme":"# Easiest JS Validator\n\n\u003ca href=\"https://gocanto.github.io/easiest-js-validator/\"\u003e\u003cimg src=\"https://img.shields.io/badge/online-demo-green.svg\" alt=\"Demo\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/easiest-js-validator\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/easiest-js-validator.svg\" alt=\"Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/easiest-js-validator\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/easiest-js-validator.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/easiest-js-validator\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/easiest-js-validator.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/gocanto/easiest-js-validator/blob/development/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/easiest-js-validator.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\nIt is a simple library ready to pull in into your project. Its goal is to provide an easy way to validate HTML forms without the headache of adapting any other complicated packages. Also, it was written in es2015, so you can get your feet wet with this amazing new way of working with JS.\n\n# Installation\nTo install this package you just need to open your console line and type ```npm i easiest-js-validator```. If there is a problem during the installation, you can try again using the ```force param``` as so ```npm i -f easiest-js-validator```\n\n\n# Gettings started\nFirst of all, you will have to import the library into the file where you are operating. As so,\n\n```js\nimport Validator from 'easiest-js-validator';\n```\n\nTake a look at the \u003ca href=\"https://github.com/gocanto/easiest-js-validator/blob/development/src/js/demo.js#L2\" target=\"_blank\"\u003eexample\u003c/a\u003e published.\n\n# illustration\n\n![example](https://github.com/gocanto/easiest-js-validator/blob/development/src/images/demo.gif)\n\n\nAlso, you will be able to see the online \u003ca href=\"https://gocanto.github.io/easiest-js-validator/\" target=\"_blank\"\u003eDEMO\u003c/a\u003e\n\n\n# Validation rules array\n\nThis array contains all the information about the form fields that you want to be validated where its keys are the same as your form object, As so:\n\n```html\n\u003c!-- input example is linked through VUEJS --\u003e\n\u003cinput type=\"text\" v-model = \"profile.first_name\"\u003e\n```\n\n```js\n//rules object\nrules: {\n     first_name: 'required,alpha',\n     last_name: 'required,alpha',\n     email: 'required,email',\n     address: 'required',\n}\n```\n\u003ca href=\"https://github.com/gocanto/easiest-js-validator/blob/development/src/js/demo.js#L14\" target=\"_blank\"\u003eImplementation\u003c/a\u003e\n\n\n```js\n//form object\nprofile: {\n     first_name,\n     last_name,\n     email,\n     address,\n}\n```\n\u003ca href=\"https://github.com/gocanto/easiest-js-validator/blob/development/src/js/demo.js#L12\" target=\"_blank\"\u003eImplementation\u003c/a\u003e\n\n\n\n# Invoke the validator class\nAt this point, we just have to call the static method ```make``` into the validator class and pass the info which it will operate. As so,\n\n```js\nlet validate = Validator.make(profile, rules, messages);\n```\n\nWhere messages will be the responsible of bringing the language into the class, in order for it to offer a better output, such as field is required, email is not valid, etc. It is important to know that messages have to meet the same structure as profile object.\n\n```js\n//messages object example\nmessages: {\n     first_name: 'required',\n     email: 'must have a valid format'\n}\n```\n\u003ca href=\"https://github.com/gocanto/easiest-js-validator/blob/development/src/js/demo.js#L24\" target=\"_blank\"\u003eImplementation\u003c/a\u003e\n\n\n\n# If there were errors\n\nIf there were errors, you will have an associative array using how reference the exactly field that does not meet the rules. as so,\n\n```js\nerrors = [\n    first_name: \"The field is required.\",\n    last_name: \"The field is required.\",\n    email: \"The email field must be a valid email address.\",\n    address: \"The field is required.\"\n]\n```\n\u003ca href=\"https://github.com/gocanto/easiest-js-validator/blob/development/src/js/demo.js#L45\" target=\"_blank\"\u003eImplementation\u003c/a\u003e\n\n\n\nNow, you have access to the validation messages and can proceed as you want.\n\n# How can I see if my field has errors?\nThis is easy enough. You only have to check the returned array and show the result on the form in the best way for you. As so,\n\n```js\nhasError: function (key)\n{\n     return typeof errors[key] !== 'undefined';\n}\n\nif (hasError('first_name')) {\n     console.log(errors['first_name'])\n}\n\n```\n\nYou can see the demo on \u003ca href=\"https://gocanto.github.io/easiest-js-validator/\" target=\"_blank\"\u003eDEMO\u003c/a\u003e\n\n\n# Features\n\nYou will be able to validate you forms againts any of this rules: \n\n* url\n* integer\n* numeric\n* alphaNum\n* email\n* alpha\n* required\n* digits\n* length\n* blank\n* dateISO\n* phoneNumber\n\n\n# Summary\nIn spite of the demo was written in vuejs, you will be able to pull in the ```validator class under any other js framework``` \n\nIf you have any question, shoot me an email. I will be glad of helping you out.\n\n# Contributing\n\nPlease feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.\n\n\n# License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n\n# How can I thank you?\nWhy not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter? Spread the word!\n\n\nDon't forget to [follow me on twitter](https://twitter.com/gocanto)!\n\nThanks!\n\nGustavo Ocanto.\ngustavoocanto@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocanto%2Feasiest-js-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgocanto%2Feasiest-js-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocanto%2Feasiest-js-validator/lists"}