@zipbul/baker 3.2.0 → 3.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zipbul/baker
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 317e536: Add the `isStatelessRegExp` type-checker rule: a value is valid if it is a `RegExp`
8
+ without the `g` (global) or `y` (sticky) flag. Those two flags make
9
+ `RegExp.prototype.test`/`exec` mutate `lastIndex` across calls, so a regex carrying them
10
+ produces order-dependent results when reused as a single-shot matcher. `isStatelessRegExp`
11
+ rejects them at validation time (all other flags — `d`, `i`, `m`, `s`, `u`, `v` — are
12
+ stateless and pass). It is the safe-form sibling of `isRegExp` (which is unchanged).
13
+ Exported from `@zipbul/baker/rules`.
14
+
3
15
  ## 3.2.0
4
16
 
5
17
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- export { isString, isNumber, isBoolean, isDate, isEnum, isInt, isArray, isObject, isRegExp, isFunction } from './typechecker';
1
+ export { isString, isNumber, isBoolean, isDate, isEnum, isInt, isArray, isObject, isRegExp, isFunction, isStatelessRegExp, } from './typechecker';
2
2
  export type { IsNumberOptions } from './typechecker';
3
3
  export { oneOf, arrayEvery } from './combinators';
4
4
  export { min, max, isPositive, isNegative, isDivisibleBy } from './number';
@@ -1,4 +1,4 @@
1
- export { isString, isNumber, isBoolean, isDate, isEnum, isInt, isArray, isObject, isRegExp, isFunction } from './typechecker.js';
1
+ export { isString, isNumber, isBoolean, isDate, isEnum, isInt, isArray, isObject, isRegExp, isFunction, isStatelessRegExp, } from './typechecker.js';
2
2
  export { oneOf, arrayEvery } from './combinators.js';
3
3
  export { min, max, isPositive, isNegative, isDivisibleBy } from './number.js';
4
4
  export { minDate, maxDate } from './date.js';
@@ -14,3 +14,4 @@ export declare const isArray: import("../types").InternalRule;
14
14
  export declare const isObject: import("../types").InternalRule;
15
15
  export declare const isRegExp: import("../types").InternalRule;
16
16
  export declare const isFunction: import("../types").InternalRule;
17
+ export declare const isStatelessRegExp: import("../types").InternalRule;
@@ -159,3 +159,13 @@ export const isFunction = makeRule({
159
159
  validate: value => typeof value === 'function',
160
160
  emit: (varName, ctx) => `if (typeof ${varName} !== 'function') ${ctx.fail('isFunction')};`,
161
161
  });
162
+ // ─────────────────────────────────────────────────────────────────────────────
163
+ // isStatelessRegExp — RegExp without g/y (the only flags that mutate lastIndex
164
+ // across repeated test()/exec()). Safe for reuse as a single-shot matcher.
165
+ // ─────────────────────────────────────────────────────────────────────────────
166
+ export const isStatelessRegExp = makeRule({
167
+ name: 'isStatelessRegExp',
168
+ constraints: {},
169
+ validate: value => value instanceof RegExp && !value.global && !value.sticky,
170
+ emit: (varName, ctx) => `if (!(${varName} instanceof RegExp) || ${varName}.global || ${varName}.sticky) ${ctx.fail('isStatelessRegExp')};`,
171
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipbul/baker",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Bun-only AOT decorator-based DTO validation & serialization. class-validator DX, sealed code generation, zero reflect-metadata.",
5
5
  "keywords": [
6
6
  "aot",