Giter Site home page Giter Site logo

ember-i18n-cp-validations's Introduction

ember-i18n-cp-validations

Adds support for ember-i18n in ember-cp-validations

Installation

  • ember install ember-i18n-cp-validations

Configuring

Implement the following validation messages across your translations:

// app/locales/en/translations.js
export default {
  errors: {
    description: "This field",
    inclusion: "{{description}} is not included in the list",
    exclusion: "{{description}} is reserved",
    invalid: "{{description}} is invalid",
    confirmation: "{{description}} doesn't match {{attribute}}",
    accepted: "{{description}} must be accepted",
    empty: "{{description}} can't be empty",
    blank: "{{description}} can't be blank",
    present: "{{description}} must be blank",
    collection: "{{description}} must be a collection",
    singular: "{{description}} can't be a collection",
    tooLong: "{{description}} is too long (maximum is {{count}} characters)",
    tooShort: "{{description}} is too short (minimum is {{count}} characters)",
    before: "{{description}} must be before {date}",
    after: "{{description}} must be after {date}",
    wrongDateFormat: "{{description}} must be in the format of {{date}}",
    wrongLength: "{{description}} is the wrong length (should be {{count}} characters)",
    notANumber: "{{description}} is not a number",
    notAnInteger: "{{description}} must be an integer",
    greaterThan: "{{description}} must be greater than {{count}}",
    greaterThanOrEqualTo: "{{description}} must be greater than or equal to {{count}}",
    equalTo: "{{description}} must be equal to {{count}}",
    lessThan: "{{description}} must be less than {{count}}",
    lessThanOrEqualTo: "{{description}} must be less than or equal to {{count}}",
    otherThan: "{{description}} must be other than {{count}}",
    odd: "{{description}} must be odd",
    even: "{{description}} must be even",
    positive: "{{description}} must be positive",
    date: "{{description}} must be a valid date",
    email: "{{description}} must be a valid email address",
    phone: "{{description}} must be a valid phone number",
    url: "{{description}} must be a valid url"
  }
};

Customizing the prefix

To 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 ammend your translation files to be nested under the validationErrors object instead of errors.

// app/validators/messages.js

import ValidatorsMessages from 'ember-cp-validations/validators/messages';

export default ValidatorsMessages.extend({
  prefix: 'validationErrors'
});

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

ember-i18n-cp-validations's People

Contributors

jasonmit avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.