summaryrefslogtreecommitdiff
path: root/utils/validate_identifier.ts
blob: e2a1dc54e59e99c7c7db1ed31b9ec231d0d47de7 (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, unknown>,
): Array<[string, unknown]> => {
  return Object.entries(obj).filter((e) =>
    !e.every((x) => typeof x === "string" && validateIdentifier(x))
  );
};