Files
js/utils/validations.ts
T
859320b6ed feat: add bundle ids to keys (#1404)
* feat: add bundle ids to keys

completes FTD-1886

* typo

* fix ui bug

* Update sdks

* Merge branch 'ta/keys-add-bundle-ids' of https://github.com/thirdweb-dev/dashboard into ta/keys-add-bundle-ids

* Fix build

* Update sdks

* hide services

* fix count

* update nightly

* update to [email protected]

* fixes

* dont hide rpc

* copy - remove thirdwebs

* missing form values

* dont be smart about none

* feat: validate api keys (#1406)

completes FTD-1826

* Add descriptions

---------

Co-authored-by: Nacho Iacovino <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2023-07-17 22:10:55 +00:00

18 lines
420 B
TypeScript

export const validStrList = (
strList: string,
validator: RegExp | ((str: string) => boolean),
) => {
if (strList === "*" || strList.length === 0) {
return true;
}
// comma or new-line separated
const values = strList.split(/,|\n/);
const invalid = values.find((str) =>
typeof validator === "function"
? !validator(str.trim())
: !validator.test(str.trim()),
);
return !invalid;
};