Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonchurch/is-stripe-key
https://github.com/jonchurch/is-stripe-key
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jonchurch/is-stripe-key
- Owner: jonchurch
- Created: 2020-05-28T20:14:22.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-28T20:40:37.000Z (over 4 years ago)
- Last Synced: 2024-10-06T14:40:46.888Z (3 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# `isStripeKey()`
Checks if a string is formatted like a Stripe API key.
## Usage
### isStripeKey(string, [options])
Returns `true` if the passed string matches the format of a Stripe API key.
```javascript
const isStripeKey = require("is-stripe-key");isStripeKey("sk_live_vQp5vQIibsjlRWJm5nkMobJW00K8o8uW7q");
// returns trueisStripeKey("sk_test_vQp5vQIibsjlRWJm5nkMobJW00K8o8uW7q");
// returns trueisStripeKey("pk_live_vQp5vQIibsjlRWJm5nkMobJW00K8o8uW7q");
// returns trueisStripeKey("sk_live_vQp5vQ", { exact: false });
// returns trueisStripeKey("sk_live_vQp5vQ");
// returns false
```The optional `options` parameter specifies the behavior of the matching.
| Property | Description | Type | Default |
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------- |
| `exact` | If the matching regex should use the most exact match, where the entire key must be exactly 32 characters long after trimming whitespace. | Boolean | `true` |