Skip to content

Add OneOf assert#275

Open
josecarlosbrandao wants to merge 1 commit intomasterfrom
feature/add-one-of-assert
Open

Add OneOf assert#275
josecarlosbrandao wants to merge 1 commit intomasterfrom
feature/add-one-of-assert

Conversation

@josecarlosbrandao
Copy link

@josecarlosbrandao josecarlosbrandao commented Feb 12, 2026

Add new assert to allow one of constraints (1 exclusive match)

Added this here because https://github.com/uphold/paypal-client/pull/60 required this type of validation to have more readable code

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new OneOf assert to the validator.js-asserts package, along with exports, TypeScript typings, and tests to validate behavior.

Changes:

  • Added OneOf assert implementation (src/asserts/one-of-assert.js) and exported it from src/index.js.
  • Added TypeScript definition for oneOf(...) in src/types/index.d.ts.
  • Updated test suite to include OneOf in the export list and added dedicated OneOf tests.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/index.test.js Updates the expected exported assert count and list to include OneOf.
test/asserts/one-of-assert.test.js Adds unit tests covering OneOf validation and violation aggregation behavior.
src/types/index.d.ts Adds the oneOf(...constraintSets) TypeScript API definition.
src/index.js Exports the new OneOf assert from the package entry point.
src/asserts/one-of-assert.js Implements OneOf validation against multiple constraint sets using validator.js constraints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@josecarlosbrandao josecarlosbrandao force-pushed the feature/add-one-of-assert branch from 52d45c3 to ffc4601 Compare February 12, 2026 11:15
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