Skip to content

Commit

Permalink
Use Zod refine for regex (#1392)
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra-tacc authored Aug 14, 2024
1 parent b6b1d03 commit 7b262fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/modules/workspace/src/AppsWizard/AppsFormSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ const FormSchema = (
if (param.notes?.validator?.regex && param.notes?.validator?.message) {
try {
const regex = RegExp(param.notes.validator.regex);
parameterSetSchema[field.label] = (<z.ZodString>(
parameterSetSchema[field.label]
)).regex(regex, param.notes.validator.message);
parameterSetSchema[field.label] = parameterSetSchema[
field.label
].refine((value) => regex.test(value), {
message: param.notes.validator.message,
});
} catch (SyntaxError) {
console.warn('Invalid regex pattern for app');
}
Expand Down

0 comments on commit 7b262fb

Please sign in to comment.