{"id":15161425,"url":"https://github.com/blimmer/ember-validate-js","last_synced_at":"2025-09-30T13:32:23.369Z","repository":{"id":57224491,"uuid":"41935872","full_name":"blimmer/ember-validate-js","owner":"blimmer","description":"[DEPRECATED] A computed-properties driven validations library for Ember.JS powered by validate.js","archived":true,"fork":false,"pushed_at":"2015-09-09T04:22:52.000Z","size":260,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-04-14T13:56:49.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/blimmer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-04T20:14:32.000Z","updated_at":"2024-04-14T13:56:49.294Z","dependencies_parsed_at":"2022-09-04T06:02:44.185Z","dependency_job_id":null,"html_url":"https://github.com/blimmer/ember-validate-js","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-validate-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-validate-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-validate-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blimmer%2Fember-validate-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blimmer","download_url":"https://codeload.github.com/blimmer/ember-validate-js/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234744628,"owners_count":18879955,"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":"2024-09-27T00:20:27.796Z","updated_at":"2025-09-30T13:32:22.957Z","avatar_url":"https://github.com/blimmer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-validate-js\n[![Build Status](https://travis-ci.org/blimmer/ember-validate-js.svg?branch=master)](https://travis-ci.org/blimmer/ember-validate-js)\n\nA flexible validations library powered by Ember computed properties and  [validate.js](http://validatejs.org/).\n\n# DEPRECATED\nIt seems like everyone and their brother wanted to write a new validations library at the same time. In the interest of reducing fragmentation, this project will be deprecated in favor of [ember-cp-validations](https://github.com/offirgolan/ember-cp-validations). \n\n## Features\n* **Driven by computed properties**\n\n  No more observers or calling `.validate()` to validate your object.\n\n* **Flexible**\n\n  Use it on a plain ol' Ember Object or with an ember-data model.\n\n* **Change constraints on the fly (coming soon)**\n\n  Change constraints on the fly and everything updates as you'd expect. Track the progress [here](https://github.com/blimmer/ember-validate-js/issues/3), help is welcome.\n\n* **Works with 1.12.x and 1.13.x (and likely earlier)**\n\n  We all want to be on the latest and greatest version of Ember, but sometimes\n  it's just not possible right away. This library is definitely compatible with\n  Ember 1.13, and unofficially compatible with 1.12.x and below (I'll do my best\n  to support it for a while).\n\n## Usage\n1. Mix the `ValidationMixin` into the Object you want to apply validations.\n\n  ```js\n  import Ember from 'ember';\n  import ValidationMixin from 'ember-validate-js/mixins/validation';\n\n  export default Ember.Object.extend(ValidationMixin, {\n    ...\n  });\n  ```\n\n  or an Ember Data Model\n\n  ```js\n  import DS from 'ember-data';\n  import ValidationMixin from 'ember-validate-js/mixins/validation';\n\n  export default DS.Model.extend(ValidationMixin, {\n    ...\n  });\n  ```\n\n2. Provide a `constraints` property on the object you've mixed the `ValidationMixin` into.\nThese constraints are passed to the ValidateJS library and used to validate the properties on your object. See the [ValidateJS documentation](http://validatejs.org/#constraints) for more a list of [available validators](http://validatejs.org/#validators).\n\n  ```js\n    constraints: Ember.computed(function() {\n      return {\n        name: {\n          presence: true\n        },\n        password: {\n          presence: {message: 'you gotta tell us your name'},\n          length: {minimum: 5}\n        },\n        passwordConfirmation: {\n          presence: true,\n          equality: 'password'\n        }\n      };\n    })\n  ```\n\n3. Use the auto-generated computed properties to check validity.\n\n  Each property gets three helpers (not that \"property\" below is replaced with the name of the property):\n\n    * **(property)Errors**\n\n      An array of validation errors. If there are no errors, the array will be empty.\n\n    * **(property)Error**\n\n      A convenience accessor for the first error in the errors array. Useful for showing a single error to the user at a time.\n\n    * **(property)IsValid**\n\n      A boolean to check if the property is valid.\n\n  And the whole object gets validity properties:\n\n    * **constraintsMet**\n\n      A boolean to check if all properties with validations are valid on the model.\n\n    * **constraintsNotMet**\n\n      The inverse of `constraintsMet`.\n\n## Example\n\nFor example, imagine you have a `User` model that you use to register a new user.\n\n### app/models/user.js\n```js\nimport Ember from 'ember';\nimport DS from 'ember-data';\nimport ValidationMixin from 'ember-validate-js/mixins/validation';\n\nconst attr = DS.attr;\n\nexport default DS.Model.extend(ValidationMixin, {\n  name:                 attr('string'),\n  email:                attr('string'),\n  password:             attr('string'),\n  passwordConfirmation: attr('string'),\n\n  // See ValidateJS documentation for available\n  // validators\n  constraints: Ember.computed(function() {\n    return {\n      name: {\n        presence: true\n      },\n      email: {\n        presence: true,\n        email: true\n      },\n      password: {\n        presence: true,\n        length: {minimum: 5, maximum: 128}\n      },\n      passwordConfirmation: {\n        presence: true,\n        equality: 'password'\n      }\n    };\n  })\n});\n```\n\n### app/templates/components/sign-up-form.hbs\n```handlebars\n\u003cform\u003e\n  \u003cdiv\u003e\n    \u003ch3\u003eName\u003c/h3\u003e\n    {{input value=user.name}}\n    {{user.nameError}}\n  \u003c/div\u003e\n  \u003cdiv\u003e\n    \u003ch3\u003eEmail\u003c/h3\u003e\n    {{input value=user.email}}\n    {{user.emailError}}\n  \u003c/div\u003e\n  \u003cdiv\u003e\n    \u003ch3\u003ePassword\u003c/h3\u003e\n    {{input type='password' value=user.password}}\n    {{user.passwordError}}\n  \u003c/div\u003e\n  \u003cdiv\u003e\n    \u003ch3\u003eConfirm Password\u003c/h3\u003e\n    {{input type='password' value=user.passwordConfirmation}}\n    {{user.passwordConfirmationError}}\n  \u003c/div\u003e\n\n  \u003cbutton {{action 'submit'}} disabled={{user.constraintsNotMet}}\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\n\n## Browser Support\nThis project relies on `Object.keys`, so its use on obsolete browsers (IE8) will require a polyfill not provided by this project.\n\n## Installation\nRun `ember install ember-validate-js` in your Ember CLI application.\n\nIf you `npm install` this app, you'll need to run `ember g ember-validate-js`\nto ensure the dependencies are installed and set up\n([ember-browserify](https://github.com/ef4/ember-browserify) and [ValidateJS](http://validatejs.org/)).\n\n# Development\nThis project works as is, but there are plenty of enhancements to make it better. My ideas are [listed here](https://github.com/blimmer/ember-validate-js/labels/enhancement) and PRs (with tests) are welcome!\n\n## Author\n[Ben Limmer](http://benlimmer.com)\n\n## Installing\n* `git clone` this repository\n* `npm install`\n* `bower install`\n\n## Running\n\n* `ember server`\n* Visit the dummy app at http://localhost:4200.\n\n## Running Tests\n\n* `ember test`\n* `ember test --server`\n\n## Building\n\n* `ember build`\n\nFor more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblimmer%2Fember-validate-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblimmer%2Fember-validate-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblimmer%2Fember-validate-js/lists"}