* 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]>
19 lines
431 B
TypeScript
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;
|
|
};
|