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

xsc-angular2-validator

v1.0.2

Published

XCEL Corp presents XSCValidator for Angular 2 Custom Validation using jQuery. Inspired from jQuery Validation, the validator is easy to use with HTML. Additional attributes could be used on the elements with minimum effort.

Downloads

27

Readme

N|XCEL Corp

Description

Angular2 custom validation, inspired by jQuery validation.

Demo

See demo

Install

npm install xsc-angular2-validator

system.config.js


map: {
      // other stuff... 
      'xsc-angular2-validator': 'npm:xsc-angular2-validator'
    },
packages: {
    // other stuf... 
    'xsc-angular2-validator': {
      main: 'index',
      defaultExtension: 'js'
    },
}

Validators

  • Compare
  • Email
  • Lowercase
  • Maxchecked
  • Maxlength
  • Maxnumber
  • Minchecked
  • Minlength
  • Minnumber
  • Numeric
  • Pattern
  • Phone
  • Range
  • Required
  • String
  • Uppercase
  • URL

How to use it

HTML

<form id="validationform">
  <div class="form-group">
      <label for="recipient-name" class="form-control-label">First Name:</label>
      <input type="text" class="form-control" id="first_name" name="first_name" value="" validation="required|email|minlength(5)|maxlength(10)|minchecked(2)|maxchecked(4)|range(1,2)|compare(#last_name)|url|phone|minnumber(2)|maxnumber(4)|pattern" pattern="/^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/" nice-name="First Name" error-tag="#first-name-error">
      <span id="first-name-error"></span>
  </div>
  <button class="btn btn-primary" type="button" (click)="save();">Add</button>
</form>

NOTE

Mandatory Attributes:

  • validation : which holds the validation rules (<input validation="required|maxLength[5]")
  • error-tag : which holds the error tag element class or id (<input error-tag="#first-name-error")
  • pattern : Which is input attribute, used to mention pattern ()

Optional Attributes:

  • nice-name : which would say beautiful name for the field (<input nice-name="First Name")

ts File

import { Component, OnInit } from '@angular/core';
import { XSCValidator } from 'xsc-angular2-validator';

@Component({
  moduleId: module.id,
  selector: 'app-root',
  templateUrl: 'app.component.html',
})
export class AppComponent implements OnInit {
  
  //An object for XSCValidator class
  Validator = new XSCValidator();
  
  save() 
  {
    var formID = 'validationform';
    var status = this.Validator.isValid(formID);
    alert('Form status : ' + status);
    //status holds form status ( true -> form is valid, false -> form is invalid )
  }
}