summaryrefslogtreecommitdiff
path: root/utils/validate_identifier.ts
blob: c204497fc6ed086cc739533dbe56add511db18ce (plain)
1
2
3
4
5
6
7
8
9
10
11
export const validateIdentifier = (token: string) => {
  return (/^[a-zA-Z0-9_\-:. \/]+$/).test(token) && !token.includes("..");
};

export const invalidExecutionEntriesOf = (
  obj: Record<string, string>,
): Array<[string, string]> => {
  return Object.entries(obj).filter((e) =>
    !e.every((x) => typeof x === "string" && validateIdentifier(x))
  );
};