Pipes Reference: Validation Pipes
Pipes used for validating input data formats and extracting validation metadata.
This section defines Pipes used for validating input data formats and extracting validation metadata. These include:
validateCreditCardNumbervalidateCreditCardExpirationvalidateEmailFormatcreditCardDetails
validateCreditCardNumber
- Usage Syntax:
{{ cardNumber | validateCreditCardNumber }} - Evaluates to: boolean
- Description: The validateCreditCardNumber pipe validates a credit card number using the Luhn algorithm (also known as the modulus 10 algorithm).
- Checks that the card number passes the Luhn checksum validation.
- Does not verify that the card is active, has funds, or belongs to a specific issuer.
- Accepts card numbers with or without spaces/dashes.
- Useful for:
- Client-side validation before payment processing.
- Form validation to catch typos or invalid numbers.
- Pre-flight checks before API calls.
- Parameters: This pipe does not accept additional parameters.
- Returns:
- boolean: true if the card number passes Luhn validation; otherwise false.
- Example 1: Valid card number
{{ '4532015112830366' | validateCreditCardNumber }}- Output: true
- Example 2: Invalid card number
{{ '1234567890123456' | validateCreditCardNumber }}- Output: false
- Example 3: Card number with spaces
{{ '4532 0151 1283 0366' | validateCreditCardNumber }}- Output: true
- Example 4: Non-numeric input
{{ 'not-a-number' | validateCreditCardNumber }}- Output: false
- Notes:
- Uses the Luhn algorithm to validate card number checksums.
- This validation does NOT confirm card is active, has available credit, or belongs to a real account.
- Spaces and dashes are automatically stripped before validation.
- Empty strings or null values return false.
validateCreditCardExpiration
- Usage Syntax:
{{ expirationDate | validateCreditCardExpiration }} - Evaluates to: boolean
- Description: The validateCreditCardExpiration pipe validates whether a credit card expiration date is in a valid format and has not expired.
- Accepts common expiration formats: MM/YY, MM/YYYY, MMYY, or MM-YY.
- Compares the expiration date against the current date.
- Returns false if the card has expired or the format is invalid.
- Useful for:
- Form validation for payment fields.
- Checking card validity before processing.
- Client-side expiration checks.
- Parameters: This pipe does not accept additional parameters.
- Returns:
- boolean: true if the expiration date is valid and not expired; otherwise false.
- Example 1: Valid future expiration
{{ '12/25' | validateCreditCardExpiration }}- Output: true (if current date is before December 2025)
- Example 2: Expired date
{{ '01/20' | validateCreditCardExpiration }}- Output: false (January 2020 has passed)
- Example 3: Different format
{{ '0625' | validateCreditCardExpiration }}- Output: true (if current date is before June 2025)
- Example 4: Invalid format
{{ '13/25' | validateCreditCardExpiration }}- Output: false (month 13 is invalid)
- Notes:
- Expiration is checked against the last day of the specified month.
- Supports multiple common date formats automatically.
- Invalid month values (00, 13+) return false.
- This validation does NOT confirm the card is active or valid with the issuer.
validateEmailFormat
- Usage Syntax:
{{ emailAddress | validateEmailFormat }} - Evaluates to: boolean
- Description: The validateEmailFormat pipe validates whether a string matches standard email address format patterns.
- Uses regex pattern matching to check email structure.
- Validates basic email format: [email protected].
- Does not verify that the email address exists or can receive mail.
- Useful for:
- Form validation for email input fields.
- Data quality checks before storing user information.
- Client-side validation before API submission.
- Parameters: This pipe does not accept additional parameters.
- Returns:
- boolean: true if the input matches valid email format; otherwise false.
- Example 1: Valid email address
{{ '[email protected]' | validateEmailFormat }}- Output: true
- Example 2: Email with subdomain
{{ '[email protected]' | validateEmailFormat }}- Output: true
- Example 3: Missing @ symbol
{{ 'userexample.com' | validateEmailFormat }}- Output: false
- Example 4: Invalid format
{{ 'user@' | validateEmailFormat }}- Output: false
- Notes:
- This validation checks format only, not deliverability.
- Does not verify the email address exists or can receive messages.
- Accepts standard email formats with subdomains and country-code TLDs.
- Empty strings or null values return false.
creditCardDetails
- Usage Syntax:
{{ cardNumber | creditCardDetails }} - Evaluates to: object
- Description: The creditCardDetails pipe analyzes a credit card number and returns metadata about the card, including the card type (issuer) and formatting information.
- Identifies card type based on number patterns (Visa, Mastercard, American Express, Discover, etc.).
- Returns an object containing card brand, validation status, and formatting details.
- Does not validate that the card is active or belongs to a real account.
- Useful for:
- Displaying appropriate card brand icons in payment forms.
- Formatting card numbers with correct spacing.
- Providing user feedback about card type.
- Parameters: This pipe does not accept additional parameters.
- Returns:
- object: An object containing card metadata including type/brand, validation status, and formatting information. Returns !error if input is not a valid card number format.
- Example 1: Visa card
{{ '4532015112830366' | creditCardDetails }}- Output: { type: 'visa', valid: true, length: 16 }
- Example 2: American Express card
{{ '378282246310005' | creditCardDetails }}- Output: { type: 'amex', valid: true, length: 15 }
- Example 3: Mastercard
{{ '5425233430109903' | creditCardDetails }}- Output: { type: 'mastercard', valid: true, length: 16 }
- Example 4: Invalid number
{{ '1234567890' | creditCardDetails }}- Output: { type: 'unknown', valid: false }
- Notes:
- Identifies major card brands: Visa, Mastercard, American Express, Discover, JCB, Diners Club.
- The valid property indicates whether the number passes Luhn algorithm validation.
- Card type detection is based on standard IIN (Issuer Identification Number) ranges.
- This does NOT verify the card is active or has available funds.
Did this answer your question?
