@optique/core 1.0.0-dev.893 → 1.0.0-dev.896

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -317,16 +317,11 @@ function integer(options) {
317
317
  $mode: "sync",
318
318
  metavar: metavar$1,
319
319
  parse(input) {
320
- let value;
321
- try {
322
- value = BigInt(input);
323
- } catch (e) {
324
- if (e instanceof SyntaxError) return {
325
- success: false,
326
- error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
327
- };
328
- throw e;
329
- }
320
+ if (!input.match(/^-?\d+$/)) return {
321
+ success: false,
322
+ error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
323
+ };
324
+ const value = BigInt(input);
330
325
  if (options.min != null && value < options.min) return {
331
326
  success: false,
332
327
  error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
@@ -854,16 +849,11 @@ function port(options) {
854
849
  $mode: "sync",
855
850
  metavar: metavar$1,
856
851
  parse(input) {
857
- let value;
858
- try {
859
- value = BigInt(input);
860
- } catch (e) {
861
- if (e instanceof SyntaxError) return {
862
- success: false,
863
- error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : require_message.message`Expected a valid port number, but got ${input}.`
864
- };
865
- throw e;
866
- }
852
+ if (!input.match(/^-?\d+$/)) return {
853
+ success: false,
854
+ error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : require_message.message`Expected a valid port number, but got ${input}.`
855
+ };
856
+ const value = BigInt(input);
867
857
  if (value < min$1) return {
868
858
  success: false,
869
859
  error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min$1) : options.errors.belowMinimum : require_message.message`Expected a port number greater than or equal to ${require_message.text(min$1.toLocaleString("en"))}, but got ${input}.`
@@ -317,16 +317,11 @@ function integer(options) {
317
317
  $mode: "sync",
318
318
  metavar: metavar$1,
319
319
  parse(input) {
320
- let value;
321
- try {
322
- value = BigInt(input);
323
- } catch (e) {
324
- if (e instanceof SyntaxError) return {
325
- success: false,
326
- error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : message`Expected a valid integer, but got ${input}.`
327
- };
328
- throw e;
329
- }
320
+ if (!input.match(/^-?\d+$/)) return {
321
+ success: false,
322
+ error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : message`Expected a valid integer, but got ${input}.`
323
+ };
324
+ const value = BigInt(input);
330
325
  if (options.min != null && value < options.min) return {
331
326
  success: false,
332
327
  error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : message`Expected a value greater than or equal to ${text(options.min.toLocaleString("en"))}, but got ${input}.`
@@ -854,16 +849,11 @@ function port(options) {
854
849
  $mode: "sync",
855
850
  metavar: metavar$1,
856
851
  parse(input) {
857
- let value;
858
- try {
859
- value = BigInt(input);
860
- } catch (e) {
861
- if (e instanceof SyntaxError) return {
862
- success: false,
863
- error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : message`Expected a valid port number, but got ${input}.`
864
- };
865
- throw e;
866
- }
852
+ if (!input.match(/^-?\d+$/)) return {
853
+ success: false,
854
+ error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : message`Expected a valid port number, but got ${input}.`
855
+ };
856
+ const value = BigInt(input);
867
857
  if (value < min$1) return {
868
858
  success: false,
869
859
  error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min$1) : options.errors.belowMinimum : message`Expected a port number greater than or equal to ${text(min$1.toLocaleString("en"))}, but got ${input}.`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.893+52c8345b",
3
+ "version": "1.0.0-dev.896+5a811a7f",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",