Skip to content

request: Add label support to validators, constraints, etc #201

@vladfrangu

Description

@vladfrangu

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

One of the biggest issues with shapeshift right now is that when running a validator of the form s.string.parse(input), the error received is not really useful (it just says that the validator failed, not why or where or for what).

Other modules (notably ow uses callsites to infer the label from the callsite) either allow this or use some interesting mechanisms to detect/infer the label. Since we aim for speed ⚡ here, we should probably stick to letting users provide a label (or even a label factory?)

Desired solution

Support for adding labels on validators (mayhaps s.string.label('url') instead of s.string('label') as the latter is breaking which is not ideal).

Would be nice to also have something like s.string.label((input) => translate('bad-input', input)) to allow dynamic labels in one predicate (for instance for the 1 person planning on using shapeshift in an i18n context)

Alternatives considered

Not supporting this, which is a downside...so none :D

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions