Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonchurch/is-stripe-key


https://github.com/jonchurch/is-stripe-key

Last synced: 22 days ago
JSON representation

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 true

isStripeKey("sk_test_vQp5vQIibsjlRWJm5nkMobJW00K8o8uW7q");
// returns true

isStripeKey("pk_live_vQp5vQIibsjlRWJm5nkMobJW00K8o8uW7q");
// returns true

isStripeKey("sk_live_vQp5vQ", { exact: false });
// returns true

isStripeKey("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` |