@optique/core 1.0.0-dev.467 → 1.0.0-dev.469

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.
@@ -127,10 +127,17 @@ function string(options = {}) {
127
127
  $mode: "sync",
128
128
  metavar,
129
129
  parse(input) {
130
- if (options.pattern != null && !options.pattern.test(input)) return {
131
- success: false,
132
- error: options.errors?.patternMismatch ? typeof options.errors.patternMismatch === "function" ? options.errors.patternMismatch(input, options.pattern) : options.errors.patternMismatch : require_message.message`Expected a string matching pattern ${require_message.text(options.pattern.source)}, but got ${input}.`
133
- };
130
+ if (options.pattern != null) {
131
+ const pattern = new RegExp(options.pattern.source, options.pattern.flags);
132
+ if (pattern.test(input)) return {
133
+ success: true,
134
+ value: input
135
+ };
136
+ return {
137
+ success: false,
138
+ error: options.errors?.patternMismatch ? typeof options.errors.patternMismatch === "function" ? options.errors.patternMismatch(input, options.pattern) : options.errors.patternMismatch : require_message.message`Expected a string matching pattern ${require_message.text(options.pattern.source)}, but got ${input}.`
139
+ };
140
+ }
134
141
  return {
135
142
  success: true,
136
143
  value: input
@@ -127,10 +127,17 @@ function string(options = {}) {
127
127
  $mode: "sync",
128
128
  metavar,
129
129
  parse(input) {
130
- if (options.pattern != null && !options.pattern.test(input)) return {
131
- success: false,
132
- error: options.errors?.patternMismatch ? typeof options.errors.patternMismatch === "function" ? options.errors.patternMismatch(input, options.pattern) : options.errors.patternMismatch : message`Expected a string matching pattern ${text(options.pattern.source)}, but got ${input}.`
133
- };
130
+ if (options.pattern != null) {
131
+ const pattern = new RegExp(options.pattern.source, options.pattern.flags);
132
+ if (pattern.test(input)) return {
133
+ success: true,
134
+ value: input
135
+ };
136
+ return {
137
+ success: false,
138
+ error: options.errors?.patternMismatch ? typeof options.errors.patternMismatch === "function" ? options.errors.patternMismatch(input, options.pattern) : options.errors.patternMismatch : message`Expected a string matching pattern ${text(options.pattern.source)}, but got ${input}.`
139
+ };
140
+ }
134
141
  return {
135
142
  success: true,
136
143
  value: input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.467+6cd2594b",
3
+ "version": "1.0.0-dev.469+18b80405",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -175,6 +175,7 @@
175
175
  "sideEffects": false,
176
176
  "devDependencies": {
177
177
  "@types/node": "^20.19.9",
178
+ "fast-check": "^4.5.3",
178
179
  "tsdown": "^0.13.0",
179
180
  "typescript": "^5.8.3"
180
181
  },