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

@terminus/ui-validators

v3.0.0

Published

<h1>Validators</h1>

Downloads

6

Readme

CI/CD Status Codecov MIT License
NPM version Library size

A collection of form validators.

Table of Contents

NOTE: This service is provided as a singleton by defining the providedIn property as root.

Usage

import {
  FormBuilder,
  FormGroup,
} from '@angular/forms';
import { TsValidatorsService } from '@terminus/ui-validators';


@Component({
  ...
})
export class MyComponent {
  // Create a form
  myForm: FormGroup = this.formBuilder.group({
    email: [
      null,
      [
        // Basic validator
        this.validatorsService.email(),
      ],
    ],
    greaterThan: [
      null,
      [
        // Validator with a required argument
        this.validatorsService.greaterThan(10),
      ],
    ],
  });

  constructor(
    private formBuilder: FormBuilder,
    private validatorsService: TsValidatorsService,
  ) {}

}

Available validators

| Validator | Purpose | |------------------|---------------------------------------------------------------| | creditCard | A credit card number must be valid | | email | An email address must be valid | | domain | A domain must be valid | | equalToControl | A control's value must be equal to another control's value | | greaterThan | A number must be greater than another value | | inCollection | A value must be found in a collection | | isInRange | A number must be between two numbers | | lessThan | A number must be less than another value | | lowercase | A value must contain a minimum amount of lowercase characters | | maxDate | A date must be before a maximum date | | minDate | A date must be after a minimum date | | numbers | A value must contain a minimum amount of numbers | | password | A password must meet certain requirements | | uppercase | A value must contain a minimum amount of uppercase characters | | url | A URL must be valid |

Mocking

A mocked version of the service is available for testing as TsValidatorsServiceMock from @terminus/ui-validators/testing.

The mocks consist of Jest mock functions. Based on the class value isValid the validator mock will return an error message or null.