🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ember-cli-validation-components

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-validation-components

Easy to use input components to manage all your form validation needs

Source
npmnpm
Version
0.2.4
Version published
Weekly downloads
31
138.46%
Maintainers
1
Weekly downloads
 
Created
Source

Ember-cli-validation-components

Easy to use input components to manage all your form validation needs

Build Status npm version Code Climate

This ember-cli addon provides three validated input components input, select and checkbox plus a service with several convenience functions to your app. These easy to use components make form validation easy and dare I say almost fun.

How Easy Is It?

This:

// controllers/index.js
form: Ember.A([
  {_id: "name", regex: /^[A-Za-z]+$/},
  {_id: "pin" , regex: /^\d{4}$/}
])

Plus this:

<!-- templates/index.hbs -->
{{#validated-input _id="name" formFields=form contentPosition="after" placeholder="Name"}}
  <div style="color:red">Only alpha chars</div>
{{/validated-input}}

{{#validated-input _id="pin" formFields=form contentPosition="after" placeholder="Pin Number"}}
  <div style="color:red">Pin is a four digit number</div>
{{/validated-input}}

Gives you this:

validation

Sign Me Up Already! (Installation)

NOTE: This add requires Ember version 1.13.1 or higher.

ember install ember-cli-validation-components

Service Defaults

By default the service is injected into all Controllers, Routes, Views and Components. However, this behavior is fully configurable. You can even disable auto injection completely and lazily inject the service with Ember.inject.service("formValidator").

In config/environment.js you can override the addons service defaults by modifying the formValidatorDefaults object:

module.exports = function(environment) {
  var ENV = {
    formValidatorDefaults: {
      injectionFactories: ['route', 'controller', 'view', 'component']
    }
  }
}

The key injectionFactories lets you choose which factories the service injects itself into. For example if you only need to access the formValidator service from inside controllers, you would change the injectionFactories property to ['controller']. This works with any valid registry name on the container. So you could do any combination of the following: ['component:fizz'] ['controller:buzz'] ['route:fizzbuzz'].

Optionally you could set the injectionFactories to be empty and inject the service manually on any Ember.Object registered in the container like so:

formValidator: Ember.inject.service("formValidator")

The Details

Component Examples

Form Validation Functions

Custom Field Validators (Other than regex)

Keywords

ember-addon

FAQs

Package last updated on 13 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts