Skip to content

Commit

Permalink
fix: fix param existence check in interpolation closes #2332
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 16, 2019
1 parent 009ef85 commit 9fe7936
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/index.ts
Expand Up @@ -305,7 +305,7 @@ export const isEmptyArray = (arr: any[]): boolean => {

export const interpolate = (template: string, values: Record<string, any>): string => {
return template.replace(/\{([^}]+)\}/g, (_, p): string => {
return values[p] || `{${p}}`;
return p in values ? values[p] : `{${p}}`;
});
};

Expand Down
4 changes: 2 additions & 2 deletions tests/providers/provider.js
Expand Up @@ -327,15 +327,15 @@ test('validates on rule change: testing NaN', async () => {
// flush the pending validation.
await flushPromises();

expect(error.text()).toBe('The {field} field may not be greater than {length} characters');
expect(error.text()).toBe('The {field} field may not be greater than NaN characters');

wrapper.vm.rules = {
required: true,
max: NaN
};

await flushPromises();
expect(error.text()).toBe('The {field} field may not be greater than {length} characters');
expect(error.text()).toBe('The {field} field may not be greater than NaN characters');
});

test('validates components on input by default', async () => {
Expand Down

0 comments on commit 9fe7936

Please sign in to comment.