npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-form-validation

v1.0.7

Published

AngularJS module to automate form validations

Downloads

4

Readme

angular-form-validation

Description

This advanced module for AngularJS provides you with facilities to automate form validation, error display and input decorations. No more manual application of ngClass directives to all the form elements and creating error messages for every possible input. Just install this module and provide input requirements the standard way by using native HTML5 attributes like maxlength, required and standard AngularJS directives like ngMin, ngMax and the like. No need to add directives to all the input fields.

You can configure this module to decorate forms as you see fit only once and all the forms of your application will automatically benefit from it.

Features

  • Works out of the box with almost zero configuration
  • No need to specify any additional directives besides standard input constraints
  • Has built-in supports for Bootstrap 3, see the Using Bootstrap 3 section
  • Automatically decorates valid, invalid and non-modified input fields
  • Automatically adds error messages to invalid input fields
  • Supports translations (i18n) and provides some built-in languages
  • Designed with flexibility in mind, almost every aspect of this module can be configured and overridden (see the API section of this document)
  • You can easily select DOM elements to decorate by providing custom traversing functions
  • You can change the way forms are decorated by overriding some aspects of existing decorators or by providing your own implementation of them
  • You can change the way error list is rendered by modifying default error list renderer or by providing your own implementation
  • jQuery is not required since version 1.0.3

Demo

Feel free to play with the Demo.

Installation

Dependencies

This library requires angular-input-modified module. It is used to detect modified input fields.

Install library with bower

bower install --save angular-form-validation

Add library to your page

<script type="text/javascript" src="angular-form-validation/dist/angular-form-validation.js"></script>

Use minified version: angular-form-validation.min.js in production and uncompressed version: angular-form-validation.js during development/testing.

Also, don't forget to add dependencies, see Dependencies section above.

Add dependency in your application's module definition

var application = angular.module('application', [
    // ...
    'ngFormValidation'
]);

Usage

This module is working out of the box with default settings and no configuration. However, in order to unleash it's full potential, you should provide additional configurations through exposed providers. Please see the API documentation in order to understand how to do this. It's written for real humans!

Important requirements

In order for this module to work, you must have semantically correct HTML form, i.e. all your input elements must be placed inside of a form element.

Also, all your form and input elements must have a name attributes with unique values.

Using Bootstrap 3

This module provides Bootstrap 3 support out of the box.

Just add the following code to your project:

module

    // ...
    
    .config([
        'formValidationDecorationsProvider',
        'formValidationErrorsProvider',
        function(
            formValidationDecorationsProvider,
            formValidationErrorsProvider
        ) {
            formValidationDecorationsProvider
                .useBuiltInDecorator('bootstrap')
            ;
            formValidationErrorsProvider
                .useBuiltInErrorListRenderer('bootstrap')
            ;
        }
    ])
    
    // ...
    
;

And if you want to use fontawesome icon library instead of glyphicons (default):

formValidationDecorationsProvider
    .useBuiltInDecorator('bootstrap')
        .useIconLibrary('fontawesome')
;

API

See the detailed API documentation.

Forced validation

Since version 1.0.1 of this module, input elements are not decorated in any way if they are pristine. To counter this behavior functionality called "forced validation" was introduced.

  • Call ngModel.forceValidation(true/false) to enable/disable forced validation for this input element
  • Call ngForm.forceValidation(true/false) to set forced validation on all form elements

When forced validation is enabled for an input element it will be decorated even if it's pristine.


If you want to force validation on form as soon as controller is loaded, you should use the following trick:


.controller('DefaultController', function($scope, $timeout) {
  // ...
  $timeout(function () {
    $scope.form.forceValidation(true);
  }, 0);
})

Using $timeout with zero interval makes sure, that our code is executed when compilation is complete and $scope.form is available.

Feedback

If you have found a bug or have another issue with the library - please create an issue in this GitHub repository.

If you have a question - file it with StackOverflow and send me a link to [email protected]. I will be glad to help. Also, please create a plunk to demonstrate the issue if appropriate. You can even fork our demo plunk.

Have any ideas or propositions? Feel free to contact me by E-Mail.

Cheers!

License

The MIT License (MIT)

Copyright (c) 2014 Slava Fomin II

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.