Files
js/utils/validations.ts
T
Jonas DanielsandElasticBottle 33e7a9e729 feat(api): add redirectUrls field to ApiKey (#1755)
* fix(api): add redirectUrls field to ApiKey

* test: add redirectUrls validation test

* feat: display redirecrURIs on dashboard

* chore: update helper text for redirectURIs

---------

Co-authored-by: ElasticBottle <[email protected]>
2023-10-11 20:18:53 +00:00

19 lines
431 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) => {
return typeof validator === "function"
? !validator(str.trim())
: !validator.test(str.trim());
});
return !invalid;
};