Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added JSONPath syntactic validation #561

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions packages/taco/test/conditions/base/json-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,18 @@ describe('JSONPath Validation', () => {
const invalidPath = '$.store.book[?(@.price < ]';
const result = jsonPathSchema.safeParse(invalidPath);
expect(result.success).toBe(false);
if (!result.success) {
expect(result.error.errors[0].message).toBe(
'Invalid JSONPath expression',
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not being more clear. I meant to keep the expect test but remove the if i.e. keep only

      expect(result.error.errors[0].message).toBe(
        'Invalid JSONPath expression',
      );

});

it('Invalid JSONPath: Incorrect use of brackets', () => {
const invalidPath = '$[store][book]';
const result = jsonPathSchema.safeParse(invalidPath);
expect(result.success).toBe(false);
if (!result.success) {
expect(result.error.errors[0].message).toBe(
'Invalid JSONPath expression',
);
}
});

it('Invalid JSONPath: Unclosed wildcard asterisk', () => {
const invalidPath = '$.store.book[*';
const result = jsonPathSchema.safeParse(invalidPath);
expect(result.success).toBe(false);
if (!result.success) {
expect(result.error.errors[0].message).toBe(
'Invalid JSONPath expression',
);
}
});

it('Valid JSONPath expression', () => {
Expand Down