Skip to content

feat: standard schema for validation#543

Open
florian-lefebvre wants to merge 2 commits into
bombshell-dev:mainfrom
florian-lefebvre:feat/standard-schema
Open

feat: standard schema for validation#543
florian-lefebvre wants to merge 2 commits into
bombshell-dev:mainfrom
florian-lefebvre:feat/standard-schema

Conversation

@florian-lefebvre
Copy link
Copy Markdown

@florian-lefebvre florian-lefebvre commented May 19, 2026

What does this PR do?

Allows using Standard Schema compatible libraries for validate(). Discussed on Discord.

Docs PR: bombshell-dev/docs#42

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: d071d6d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/prompts Minor
@clack/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

commit: d071d6d

Copy link
Copy Markdown
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

the jsdoc comments above the validate options would need updating, as well as the docs https://github.com/bombshell-dev/docs/

await setTimeout(1000);
}

main().catch(console.error);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

top level await? :p

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably fine since it’s just an example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

something about being the change you want to see in the world 😇

@@ -0,0 +1,22 @@
import type { StandardSchemaV1 } from '@standard-schema/spec';

export type Validate<TValue> =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could use a jsdoc comment

Copy link
Copy Markdown
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Code looks great, changeset is perfect, just minor feedback on the example!

const name = await text({
message: 'Enter your name (letters only)',
initialValue: 'John123', // Invalid initial value with numbers
validate: type('string.alpha').describe('Name can only contain letters'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To @ghostdevv s "be the change" comment, can we use a contrived number example or something neutral like a url? Names categorically cannot be validated.

// https://standardschema.dev/schema#how-to-only-allow-synchronous-validation
if (result instanceof Promise) {
throw new TypeError(
'Schema validation must be synchronous. Update `validate()` and get rid of any asynchronous logic.'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bummer that we're stuck with this! Maybe a follow-up for v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants