Skip to content

Commit

Permalink
Update JsonApiConditionSchema to match lingo
Browse files Browse the repository at this point in the history
  • Loading branch information
theref committed Jul 19, 2024
1 parent 9aa4859 commit e026564
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/taco/src/conditions/base/json-api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JSONPath } from 'jsonpath-plus';
import { z } from 'zod';

import { Condition } from '../condition';
Expand All @@ -13,7 +14,19 @@ export const JsonApiConditionSchema = z.object({
conditionType: z.literal(JsonApiConditionType).default(JsonApiConditionType),
endpoint: z.string().url(),
parameters: z.array(paramOrContextParamSchema),
query: z.string(),
query: z.string().refine(
(path) => {
try {
JSONPath.toPathArray(path);
return true;
} catch (error) {
return false;
}
},
{
message: "Invalid JSON path",
}
),
returnValueTest: returnValueTestSchema, // Update to allow multiple return values after expanding supported methods
});

Expand Down

0 comments on commit e026564

Please sign in to comment.