Skip to content

Commit

Permalink
feat: add string.endsWith support
Browse files Browse the repository at this point in the history
  • Loading branch information
ItMaga committed Jul 27, 2023
1 parent ced3c98 commit de3c648
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/generators/StringGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default class StringGenerator<T extends z.ZodString> implements BaseGener
case 'startsWith':
string = `${check.value}${string}`;
break;
case 'endsWith':
string = `${string}${check.value}`;
break;
case 'min':
case 'max':
case 'length':
Expand Down
5 changes: 5 additions & 0 deletions tests/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ describe('String', () => {
test('startsWith', () => {
const schema = z.string().startsWith('__MARK__');

expect(schema);
});
test('endsWith', () => {
const schema = z.string().endsWith('__MARK__');

expect(schema);
});
});

0 comments on commit de3c648

Please sign in to comment.