-
Notifications
You must be signed in to change notification settings - Fork 0
Allow validate() to infer description from function name #6
Copy link
Copy link
Open
Description
Per verbal request from @protiev — when using .validate() with a well-named function, having to also provide a string description is redundant:
// Redundant — the function name already says what it does
script.add('git push').validate(gitIsAvailable, 'git is available');
// Desired — just pass the function, let the name speak for itself
script.add('git push').validate(gitIsAvailable);Currently, when no description is provided, the output falls back to the generic text "Step validation". Instead, it should use the function's .name property, formatted for display (e.g. gitIsAvailable → "gitIsAvailable").
Current signature
validate(
check: () => boolean | string | Promise<boolean | string>,
description?: string,
): thisThe signature already supports omitting the description — the improvement is purely in how the fallback is displayed.
Proposed behavior
When description is omitted (or undefined):
- Use
check.nameif available (named function or named function expression) - Fall back to
"Step validation"only for anonymous/arrow functions where.nameis empty
In Script.ts line 707, change:
const desc = step.options.validateDescription || 'Step validation';to something like:
const desc = step.options.validateDescription
|| step.options.validateFn?.name
|| 'Step validation';This makes the common case of passing a named validation function a one-argument call with useful output.
(Filed from Claude Code VSCode extension, model: Claude Opus 4.6)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels