{"id":15450429,"url":"https://github.com/ember-intl/cp-validations","last_synced_at":"2025-04-19T22:59:03.177Z","repository":{"id":2725075,"uuid":"43113729","full_name":"ember-intl/cp-validations","owner":"ember-intl","description":"ember-intl support for ember-cp-validations","archived":false,"fork":false,"pushed_at":"2024-07-10T10:19:11.000Z","size":1309,"stargazers_count":10,"open_issues_count":5,"forks_count":13,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-19T22:58:58.710Z","etag":null,"topics":["ember","ember-addon","ember-cp-validations","ember-i18n","ember-intl","i18n","internationalization"],"latest_commit_sha":null,"homepage":null,"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/ember-intl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2015-09-25T06:33:32.000Z","updated_at":"2024-07-10T10:18:29.000Z","dependencies_parsed_at":"2024-06-18T20:13:43.866Z","dependency_job_id":"510365fc-e83a-4807-827f-83ef5786f591","html_url":"https://github.com/ember-intl/cp-validations","commit_stats":null,"previous_names":["jasonmit/ember-intl-cp-validations"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-intl%2Fcp-validations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-intl%2Fcp-validations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-intl%2Fcp-validations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-intl%2Fcp-validations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-intl","download_url":"https://codeload.github.com/ember-intl/cp-validations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249826669,"owners_count":21330674,"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":["ember","ember-addon","ember-cp-validations","ember-i18n","ember-intl","i18n","internationalization"],"created_at":"2024-10-01T21:05:20.246Z","updated_at":"2025-04-19T22:59:03.158Z","avatar_url":"https://github.com/ember-intl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/ember-intl/cp-validations/actions/workflows/ci.yml/badge.svg)](https://github.com/ember-intl/cp-validations/actions/workflows/ci.yml)\n[![Ember Observer Score](https://emberobserver.com/badges/-ember-intl-cp-validations.svg)](https://emberobserver.com/addons/@ember-intl/cp-validations)\n\n# @ember-intl/cp-validations\n\nAdds support for [ember-intl](https://github.com/yahoo/ember-intl) in ember-cp-validations\n\n## Requirements\n\n* Ember.js v3.28 or above\n* Node.js v18 or above\n* `ember-cp-validations` v6\n* `ember-intl` v6 or above\n\n## Installation\n\n```sh\nember install @ember-intl/cp-validations\n```\n\n## Configuration\n\nImplement the following validation messages across your translations:\n\n```yaml\n# \u003cproject root\u003e/translations/en.yaml\nerrors:\n  description: \"This field\"\n  inclusion: \"{description} is not included in the list\"\n  exclusion: \"{description} is reserved\"\n  invalid: \"{description} is invalid\"\n  confirmation: \"{description} doesn't match {on}\"\n  accepted: \"{description} must be accepted\"\n  empty: \"{description} can't be empty\"\n  blank: \"{description} can't be blank\"\n  present: \"{description} must be blank\"\n  collection: \"{description} must be a collection\"\n  singular: \"{description} can't be a collection\"\n  tooLong: \"{description} is too long (maximum is {max} characters)\"\n  tooShort: \"{description} is too short (minimum is {min} characters)\"\n  before: \"{description} must be before {before}\"\n  after: \"{description} must be after {after}\"\n  wrongDateFormat: \"{description} must be in the format of {format}\"\n  wrongLength: \"{description} is the wrong length (should be {is} characters)\"\n  notANumber: \"{description} must be a number\"\n  notAnInteger: \"{description} must be an integer\"\n  greaterThan: \"{description} must be greater than {gt}\"\n  greaterThanOrEqualTo: \"{description} must be greater than or equal to {gte}\"\n  equalTo: \"{description} must be equal to {is}\"\n  lessThan: \"{description} must be less than {lt}\"\n  lessThanOrEqualTo: \"{description} must be less than or equal to {lte}\"\n  otherThan: \"{description} must be other than {value}\"\n  odd: \"{description} must be odd\"\n  even: \"{description} must be even\"\n  positive: \"{description} must be positive\"\n  date: \"{description} must be a valid date\"\n  email: \"{description} must be a valid email address\"\n  phone: \"{description} must be a valid phone number\"\n  url: \"{description} must be a valid url\"\n```\n\n### Translating Validator description\n\nTo translate the description of a Validator specify the `descriptionKey` to match a key in your translations.\n\n```js\n// app/models/user.js\n\nimport { validator, buildValidations } from 'ember-cp-validations';\n\nconst Validations = buildValidations({\n  username: validator('presence', {\n    presence: true,\n    descriptionKey: 'key.for.username'\n  })\n});\n```\n\n```yml\n# translations/en-us.yml\nkey:\n  for:\n    username: 'Username'\n```\n\n```yml\n# translations/sv-se.yml\nkey:\n  for:\n    username: 'Användarnamn'\n```\n\n### Customizing the prefix\n\nTo change the errors prefix key from `errors` to any other key, such as `validationErrors` you simply add the following to `app/validators/messages.js`.  Now just amend your translation files to be nested under the `validationErrors` object instead of `errors`.\n\n```js\n// app/validators/messages.js\n\nimport ValidatorsMessages from '@ember-intl/cp-validations/validators/messages';\n\nexport default ValidatorsMessages.extend({\n  prefix: 'validationErrors'\n});\n```\n\n### Overriding default translation key\n\nBy default, translations will be resolved to `validatorPrefix.validatorType`.  If you need to override this functionality entirely and specify your own message key, you can do so with `messageKey` on the validator object.\n\n```js\n// app/models/user.js\n\nimport { validator, buildValidations } from 'ember-cp-validations';\n\nconst Validations = buildValidations({\n  username: validator('presence', {\n    presence: true,\n    messageKey: 'username.missing'\n  })\n});\n```\n\n```yml\n# translations/en-us.yml\nusername:\n  missing: '{description} is missing'\n```\n\n```yml\n# translations/sv-se.yml\nusername:\n  missing: '{description} saknas'\n```\n\n### Disabling Missing Translation Warnings\n\nTo suppress console warnings for missing translations, you can do so by setting `intl_cp_validations.suppressWarnings` in `config/environment`;\n\n```js\n// config/environment.js\nmodule.exports = function(environment) {\n  const ENV = {};\n\n  if (environment === 'test') {\n    ENV.intl_cp_validations = ENV.intl_cp_validations || {};\n    ENV.intl_cp_validations.suppressWarnings = true;\n  }\n\n  return ENV;\n}\n```\n\n## Contributing\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-intl%2Fcp-validations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-intl%2Fcp-validations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-intl%2Fcp-validations/lists"}