Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@angularclass/form-validators

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angularclass/form-validators

Angular 2 template form validators by @AngularClass

  • 1.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36
increased by12.5%
Maintainers
4
Weekly downloads
 
Created
Source

Angular 2 Fundamentals


Angular 2 Form Validators

Angular 2 form validators by @AngularClass

Request a validator that is missing

Submit a Request and I will create it and include it here.

Installing

npm install --save @angularclass/form-validators

Directives

ac-is-credit-card
ac-is-base-64
ac-is-email
ac-is-json
ac-is-phone
ac-is-uuid

Example

import {
  ANGULARCLASS_FORM_VALIDATOR_DIRECTIVES
}  from '@angularclass/form-validators';

@Component({
  selector: 'app',
  directives: [
    ANGULARCLASS_FORM_VALIDATOR_DIRECTIVES
  ],
  template: `
  <form>
    <input ac-is-credit-card>
    <input ac-is-base-64>
    <input ac-is-email>
    <input ac-is-json>
    <input ac-is-phone>
    <input ac-is-uuid>
  </form>
  `
})
class App {
}

Another example

import { Component } from '@angular/core';

@Component({
  selector: 'about',
  template: `
    About
    <form #form="ngForm" (ngSubmit)="onSubmit(form.value, form)" novalidate>
      <div>
        <label>
          <input
            #inputEmail="ngModel"
            name="inputEmail"
            [(ngModel)]="email"
            ac-is-email
          >
        </label>
      </div>

      <div *ngIf="form.submitted && inputEmail?.errors?.isEmail" style="background-color: red">
        Please use a valid email address
      </div>

      <button>Submit</button>

    </form>
  `
})
export class About {
  localState = {
    email: ''
  };

  onSubmit(value, form) {
    if (form.valid) {
      console.log('form value', value);
    } else {
      console.log('form invalid');
    }
  }
}

enjoy — AngularClass



AngularClass ##AngularClass

Learn AngularJS, Angular 2, and Modern Web Development from the best. Looking for corporate Angular training, want to host us, or Angular consulting? hello@angularclass.com

FAQs

Package last updated on 04 Aug 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc