Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add number range rule constructor function #1918

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ryasmi
Copy link
Owner

@ryasmi ryasmi commented Nov 8, 2024

Add a function to validate number ranges and corresponding tests.

  • New Functionality: Add numberRange function in src/valueRules/numberRange/numberRange.ts to validate if a number is within a specified range and return a constrained type with a unique symbol for each range.
  • Error Handling: Implement InvalidNumberRangeError to throw an error if the number is not within the specified range.
  • Tests: Add tests in src/valueRules/numberRange/numberRange.test.ts to validate the numberRange function with various inputs, including edge cases and type constraints.
  • Exports: Modify src/rulr.ts to export the numberRange function and InvalidNumberRangeError.

For more details, open the Copilot Workspace session.

Add a function to validate number ranges and corresponding tests.

* **New Functionality**: Add `numberRange` function in `src/valueRules/numberRange/numberRange.ts` to validate if a number is within a specified range and return a constrained type with a unique symbol for each range.
* **Error Handling**: Implement `InvalidNumberRangeError` to throw an error if the number is not within the specified range.
* **Tests**: Add tests in `src/valueRules/numberRange/numberRange.test.ts` to validate the `numberRange` function with various inputs, including edge cases and type constraints.
* **Exports**: Modify `src/rulr.ts` to export the `numberRange` function and `InvalidNumberRangeError`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ryasmi/rulr?shareId=XXXX-XXXX-XXXX-XXXX).
* **numberRange function**: Define and implement `numberRange` function in `src/ruleConstructors/numberRange/numberRange.ts` to validate if a number is within a specified range, throwing an error if not.
* **Tests**: Add tests in `src/ruleConstructors/numberRange/numberRange.test.ts` to validate the `numberRange` function with various inputs, including edge cases and constrained type checks.
* **Export**: Change `src/rulr.ts` to import and export the `numberRange` function from the new file.
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