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

Fix copy-param to support string and number for from #967

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/__tests__/if-run/builtins/copy-param.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('builtins/copy: ', () => {
} catch (error) {
expect(error).toStrictEqual(
new InputValidationError(
'"original" parameter is required. Error code: invalid_type.'
'"original" parameter is required. Error code: invalid_union.'
)
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/if-run/builtins/copy-param/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Copy = (

const globalConfigSchema = z.object({
'keep-existing': z.boolean(),
from: z.string().min(1),
from: z.string().min(1).or(z.number()),
to: z.string().min(1),
});

Expand All @@ -51,18 +51,18 @@ export const Copy = (
*/
const validateSingleInput = (
input: PluginParams,
inputParameters: string[]
inputParameters: (string | number)[]
) => {
const inputData = inputParameters.reduce(
(acc, param) => {
acc[param] = input[param];

return acc;
},
{} as Record<string, string>
{} as Record<string, string | number>
);

const validationSchema = z.record(z.string(), z.string());
const validationSchema = z.record(z.string(), z.string().or(z.number()));

validate(validationSchema, inputData);

Expand Down