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 🙏

© 2026 – Pkg Stats / Ryan Hefner

validator-package

v1.1.6

Published

A collection of custom validators for Angular forms

Readme

Validator Package

Validator Package is an Angular package that provides various form validation functions for use in Angular reactive forms. These validators help enforce specific rules for input fields to enhance user experience and data integrity.

Functions

1. allowedOnlyKeyboardNumbers

  • Description: Purpose: Restricts input to only numeric characters (0-9) and certain control keys. Prevents non-numeric characters from being entered via the keyboard.

2. isValidEmail

  • Description: Validates if the provided email address follows a proper email format.

3. alphaNumbersSpaceValidator

  • Description: Ensures that the input starts with an alphanumeric character and does not contain leading or double spaces. Accepts alphanumeric characters and spaces.

4. alphaNumbersExceptSpaceValidator

  • Description: Validates that the input starts with an alphanumeric character and does not contain any spaces.

5. alphaNumbersExceptDoubleSpaceValidator

  • Description: Checks that the input does not start with a space and does not contain double spaces.

6. alphaSpaceValidator

  • Description: Validates that the input contains only alphabetic characters and spaces, without leading spaces or double spaces.

7. alphaNumbersValidator

  • Description: Ensures the input consists of only alphanumeric characters, without leading spaces or double spaces.

8. urlValidator

  • Description: Validates that the input is a properly formatted URL.

9. alphaValidator

  • Description: Validates that the input consists of only alphabetic characters.

10. noSpaceValidator

  • Description: Checks that the input does not contain any spaces.

11. previousDateValidator

  • Description: Validates that the date entered is not a future date.

12. currentDateValidator

  • Description: Validates that the date entered is not in the future compared to the current date.

13. defalutDateValidator

  • Description: Validates the format of the date input.

14. futureDateFromCurrentValidator

  • Description: Validates that the date entered is not in the past compared to the current date.

15. futureDateValidator

  • Description: Validates that the date entered is at least one day in the future.

16. checkFormat(selectDate: any): any

  • Description: Checks if the date input is a valid date format.

17. dateAllowedOnlyNumbers

  • Description: Restricts date input to numeric characters and certain control keys.

18. allowedOnlyRoundedNumbersValidator

  • Description: Validates that the input is a rounded number (integer).

19. allowedNumberWithDecimal

  • Description: Validates that the input is a number that may contain decimals.

20. allowedNumberDecimalWithNegative

  • Description: Validates that the input is a decimal number which may also be negative.

21. allowedOnlyNUmbersValidator

  • Description: Validates that the input consists of only numeric characters.

22. allowedOnlyCurrencyValidator

  • Description: Validates that the input consists of valid currency characters.

23. allowedOnlyPositiveNUmbersValidator

  • Description: Validates that the input consists of only positive numeric characters.

24. twoDatesValidator(second: any): ValidatorFn

  • Description: Validates that the first date is not after the second date.

25. twoDatesExpValidator(second: any): ValidatorFn

  • Description: Validates that the first date is not after the second date, with additional checks.

26. ssnValidator(min: number): ValidatorFn

  • Description: Validates the length of a Social Security Number (SSN) input.

27. numbersWithLengthValidator(min: number): ValidatorFn

  • Description: Validates that the input is numeric and meets a minimum length requirement.

28. getDate(selectDate: any): any

  • Description: Checks if a given date is greater than the current date.

29. isTouchedDirty(groupName: any, fieldName: string): boolean

  • Description: Checks if a specific form field is invalid and has been interacted with (touched or dirty).

Usage

To use the validators from the validator-package, import the necessary functions directly into your Angular component. You can then apply the validators to your form controls as needed.

Example Component Code

import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { isValidEmail, allowedOnlyKeyboardNumbers } from 'validator-package';

@Component({
  selector: 'app-my-form',
  templateUrl: './my-form.component.html'
})
export class MyFormComponent {
  myForm: FormGroup;

  constructor(private fb: FormBuilder) {
    this.myForm = this.fb.group({
      email: ['', [Validators.required, isValidEmail]],
      numberField: ['', allowedOnlyKeyboardNumbers]
    });
  }

  onSubmit() {
    if (this.myForm.valid) {
      console.log(this.myForm.value);
    }
  }
}