{"id":24362184,"url":"https://github.com/polymerelements/iron-validatable-behavior","last_synced_at":"2025-04-10T10:43:46.536Z","repository":{"id":31561955,"uuid":"35126679","full_name":"PolymerElements/iron-validatable-behavior","owner":"PolymerElements","description":"Implements an element validated with Polymer.IronValidatorBehavior","archived":false,"fork":false,"pushed_at":"2023-10-16T14:04:48.000Z","size":286,"stargazers_count":7,"open_issues_count":11,"forks_count":18,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-05-09T10:09:28.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://webcomponents.org/element/PolymerElements/iron-validatable-behavior","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/PolymerElements.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-05T22:14:50.000Z","updated_at":"2024-06-18T15:24:08.604Z","dependencies_parsed_at":"2024-06-18T15:23:59.789Z","dependency_job_id":null,"html_url":"https://github.com/PolymerElements/iron-validatable-behavior","commit_stats":{"total_commits":115,"total_committers":18,"mean_commits":6.388888888888889,"dds":0.7130434782608696,"last_synced_commit":"685828cbe64ea733772fc6095fa3dae65176d0f0"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Firon-validatable-behavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Firon-validatable-behavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Firon-validatable-behavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PolymerElements%2Firon-validatable-behavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PolymerElements","download_url":"https://codeload.github.com/PolymerElements/iron-validatable-behavior/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248200394,"owners_count":21063890,"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-01-18T22:50:16.554Z","updated_at":"2025-04-10T10:43:46.512Z","avatar_url":"https://github.com/PolymerElements.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Published on NPM](https://img.shields.io/npm/v/@polymer/iron-validatable-behavior.svg)](https://www.npmjs.com/package/@polymer/iron-validatable-behavior)\n[![Build status](https://travis-ci.org/PolymerElements/iron-validatable-behavior.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-validatable-behavior)\n[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://webcomponents.org/element/@polymer/iron-validatable-behavior)\n\n## IronValidatableBehavior\nUse `IronValidatableBehavior` to implement an element that validates user input. By using this behaviour, your custom element will get a public `validate()` method, which\nwill return the validity of the element, and a corresponding `invalid` attribute,\nwhich can be used for styling. Can be used alongside an element implementing\nthe  `IronValidatableBehavior` behaviour.\n\nSee: [Documentation](https://www.webcomponents.org/element/@polymer/iron-validatable-behavior),\n  [Demo](https://www.webcomponents.org/element/@polymer/iron-validatable-behavior/demo/demo/index.html).\n\n## Usage\n\n### Installation\n```\nnpm install --save @polymer/iron-validatable-behavior\n```\n\n### In a Polymer 3 element\n```js\nimport {PolymerElement, html} from '@polymer/polymer';\nimport {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js';\nimport {IronValidatableBehavior} from '@polymer/iron-validatable-behavior/iron-validatable-behavior.js';\n\nclass SampleElement extends mixinBehaviors([IronValidatableBehavior], PolymerElement) {\n  static get template() {\n    return html`\n      \u003cstyle\u003e\n        :host {\n          border: 1px solid green;\n          color: green;\n        }\n        :host([invalid]) {\n          border: 1px solid red;\n          color: red;\n        }\n      \u003c/style\u003e\n      \u003cinput id=\"input\"\u003e\n    `;\n\n    // Override this method if you want to implement custom validity\n    // for your element. This element is only valid if the value in the\n    // input is \"cat\".\n    function _getValidity() {\n      return this.$.input.value === 'cat';\n    }\n  }\n}\ncustomElements.define('sample-element', SampleElement);\n```\n\n### In an html file using the element\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cscript type=\"module\" src=\"./sample-element.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003csample-element id=\"el\"\u003e\u003c/sample-element\u003e\n    \u003cbutton onclick=\"el.validate()\"\u003eValidate!\u003c/button\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Contributing\nIf you want to send a PR to this element, here are\nthe instructions for running the tests and demo locally:\n\n### Installation\n```sh\ngit clone https://github.com/PolymerElements/iron-validatable-behavior\ncd iron-validatable-behavior\nnpm install\nnpm install -g polymer-cli\n```\n\n### Running the demo locally\n```sh\npolymer serve --npm\nopen http://127.0.0.1:\u003cport\u003e/demo/\n```\n\n### Running the tests\n```sh\npolymer test --npm\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolymerelements%2Firon-validatable-behavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolymerelements%2Firon-validatable-behavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolymerelements%2Firon-validatable-behavior/lists"}