Back to all patterns
Stripe Customer ID
Validation
Validates a Stripe Customer ID (cus_XXXXXXXXXXXXXX).
/^cus_[A-Za-z0-9]{14,24}$/How it works
Stripe object IDs share a consistent shape: a short type prefix, an underscore, and a base62-ish identifier. Customer IDs use the cus_ prefix.
Test Cases
Should Match
- cus_NffrFeUfNV2Hib
- cus_abc1234567890XYZ
Should NOT Match
- cust_NffrFeUfNV2Hib
- NffrFeUfNV2Hib
- cus_short
Quick Summary
Validates Stripe Customer IDs of the form cus_ followed by 14–24 alphanumeric characters.
Key Takeaways
Key Takeaways
- Stripe object IDs use a short type prefix and an underscore
- Customer IDs use cus_; charges use ch_; payment intents use pi_; subscriptions use sub_
- Length varies slightly across IDs, anchor with ^ and $ but allow a range