Getting Started
Overview
Installation
Theme
Forms
Basic Inputs
Select
Custom Inputs
Components
Navigation
Components
69
Micro Charts
Libraries
Kanban Board
Image Designer
Video Player
Visual Builder
Content Editor
Data View
Latest npm version of @ngstarter-ui/componentsWeekly npm downloads of @ngstarter-ui/components
Purchase

Input Validator

Input Validator provides ready-made Angular ValidatorFn functions for common form rules. Use these validators with FormControl, Validators.compose, NgStarter ngs-form-field, and ngs-error.

The current preset validators focus on payment fields: creditCardNumberValidator(), expiryDateValidator(), and creditCardCvvValidator(). They pair naturally with the credit card masks from Input Mask, but they do not format values themselves.

Do not use Input Validator as a UI component, input mask, replacement for Angular built-in validators, backend validation, payment processor validation, or security/compliance layer. Use it as a client-side helper for common reusable validation rules.

NameTypeDefault
creditCardNumberValidator
Validator function for credit card numbers. Cleans non-digits, checks length, and validates the Luhn checksum. Returns creditCardNumberInvalid.
ValidatorFn-
expiryDateValidator
Validator function for credit card expiry date in MMYY format. Rejects invalid months and dates in the past. Returns expiryDateInvalid or expiryDateInPast.
ValidatorFn-
creditCardCvvValidator
Validator function for numeric CVV/CVC values. Defaults to 3–4 digits and accepts optional minLength and maxLength. Returns creditCardCvvInvalid.
ValidatorFn-