From d4791f3d357634daf506fb8f91cc5332a794c421 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Fri, 20 Jun 2025 14:53:38 -0700 Subject: Move to nodejs --- u/process/validate_identifier.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'u/process/validate_identifier.ts') diff --git a/u/process/validate_identifier.ts b/u/process/validate_identifier.ts index 4e93728..1ff3791 100644 --- a/u/process/validate_identifier.ts +++ b/u/process/validate_identifier.ts @@ -1,23 +1,18 @@ -import { Either, type IEither } from "@emprespresso/pengueno"; +import { Either, type IEither } from '@emprespresso/pengueno'; export const validateIdentifier = (token: string) => { - return /^[a-zA-Z0-9_\-:. \/]+$/.test(token) && !token.includes(".."); + return /^[a-zA-Z0-9_\-:. \/]+$/.test(token) && !token.includes('..'); }; // ensure {@param obj} is a Record with stuff that won't // have the potential for shell injection, just to be super safe. type InvalidEntry = [K, T]; -export const validateExecutionEntries = < - T, - K extends symbol | number | string = symbol | number | string, ->( - obj: Record, +export const validateExecutionEntries = ( + obj: Record, ): IEither>, Record> => { - const invalidEntries = >>( - Object.entries(obj).filter( - (e) => !e.every((x) => typeof x === "string" && validateIdentifier(x)), - ) - ); - if (invalidEntries.length > 0) return Either.left(invalidEntries); - return Either.right(>obj); + const invalidEntries = >>( + Object.entries(obj).filter((e) => !e.every((x) => typeof x === 'string' && validateIdentifier(x))) + ); + if (invalidEntries.length > 0) return Either.left(invalidEntries); + return Either.right(>obj); }; -- cgit v1.2.3-70-g09d2