mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 13:15:39 +00:00
26 lines
700 B
TypeScript
26 lines
700 B
TypeScript
import RE2 from "re2";
|
|
import { z } from "zod";
|
|
|
|
const arnSchema = z
|
|
.string()
|
|
.refine(
|
|
(val) => new RE2("^acs:ram::[0-9]{16}:(user|role)/.*$").test(val),
|
|
"Invalid ARN format. Expected format: acs:ram::[0-9]{16}:(user|role)/*"
|
|
);
|
|
export const validateArns = z
|
|
.string()
|
|
.trim()
|
|
.min(1, "Allowed ARNs required")
|
|
.max(500, "Input exceeds the maximum limit of 500 characters")
|
|
.transform((val) => {
|
|
if (!val) return [];
|
|
return val
|
|
.split(",")
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
})
|
|
.refine((arr) => arr.every((name) => arnSchema.safeParse(name).success), {
|
|
message: "One or more ARNs are invalid"
|
|
})
|
|
.transform((arr) => arr.join(", "));
|