Skip to content

feat(core): add between and lengthBetween validation functions#214

Open
nil957 wants to merge 1 commit intovercel-labs:mainfrom
nil957:feat/validation-between
Open

feat(core): add between and lengthBetween validation functions#214
nil957 wants to merge 1 commit intovercel-labs:mainfrom
nil957:feat/validation-between

Conversation

@nil957
Copy link

@nil957 nil957 commented Mar 13, 2026

Summary

Adds two new convenience validation functions for common range checking scenarios.

New Functions

between

Check if a numeric value is within a range (inclusive).

{
  "type": "between",
  "args": { "min": 1, "max": 100 },
  "message": "Value must be between 1 and 100"
}

lengthBetween

Check if a string length is within a range (inclusive).

{
  "type": "lengthBetween",
  "args": { "min": 3, "max": 50 },
  "message": "Must be between 3 and 50 characters"
}

Helper Functions

Also adds corresponding check helpers:

check.between(1, 100, 'Out of range');
check.lengthBetween(3, 50, 'Invalid length');

Motivation

Currently, checking both upper and lower bounds requires two separate checks:

{
  "checks": [
    { "type": "min", "args": { "min": 1 }, "message": "Too low" },
    { "type": "max", "args": { "max": 100 }, "message": "Too high" }
  ]
}

With between, this becomes a single check with a single error message:

{
  "checks": [
    { "type": "between", "args": { "min": 1, "max": 100 }, "message": "Must be 1-100" }
  ]
}

Checklist

  • Tests added for both functions
  • Tests added for check helpers
  • No breaking changes

Adds two new convenience validation functions:

- `between`: Check if numeric value is within a range (inclusive)
- `lengthBetween`: Check if string length is within a range (inclusive)

These combine min/max and minLength/maxLength checks into single
validations, reducing boilerplate when both bounds are needed.

Also adds corresponding `check.between()` and `check.lengthBetween()`
helper functions for easier check creation.
@vercel
Copy link
Contributor

vercel bot commented Mar 13, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant