@warlock.js/seal 5.7.0 → 5.9.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 +6 -0
- package/cjs/index.cjs +20 -0
- package/cjs/index.cjs.map +1 -1
- package/esm/validators/number-validator.d.mts +20 -0
- package/esm/validators/number-validator.d.mts.map +1 -1
- package/esm/validators/number-validator.mjs +21 -1
- package/esm/validators/number-validator.mjs.map +1 -1
- package/llms-full.txt +9 -0
- package/package.json +1 -1
- package/skills/pick-seal-primitive/number-methods.md +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to `@warlock.js/seal` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.9.0 - 2026-09-13
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `.coerce()` modifier on the number validators (`int` / `number` / `float` / `numeric`): opt into parsing a numeric-shaped string (e.g. a query-string param) into a number while the type rule stays strict. `v.int()` is unchanged by default; chain `.coerce()` to accept `"2"` as `2`. The inferred output type is unaffected.
|
|
12
|
+
|
|
7
13
|
## 5.7.0 - 2026-09-11
|
|
8
14
|
|
|
9
15
|
### Changed
|
package/cjs/index.cjs
CHANGED
|
@@ -6977,6 +6977,26 @@ var NumberValidator = class extends PrimitiveValidator {
|
|
|
6977
6977
|
return this.addMutator(toFixedMutator, { decimals });
|
|
6978
6978
|
}
|
|
6979
6979
|
/**
|
|
6980
|
+
* Opt in to coercion: a numeric-shaped string is converted to a number
|
|
6981
|
+
* **before** the type rules run; any other value passes through unchanged
|
|
6982
|
+
* so bad input still fails the type rule.
|
|
6983
|
+
*
|
|
6984
|
+
* Strictness is preserved — coercion only fixes the string *representation*,
|
|
6985
|
+
* not the value's shape. `v.int().coerce()` turns `"5"` into `5` (valid) but
|
|
6986
|
+
* `"5.5"` into `5.5`, which still fails the integer rule. Number validators
|
|
6987
|
+
* do **not** coerce by default; this only takes effect when explicitly chained.
|
|
6988
|
+
*
|
|
6989
|
+
* The output type is unchanged (`Infer<>` keys off the validator class), so
|
|
6990
|
+
* `v.int().coerce()` still infers `number`.
|
|
6991
|
+
*
|
|
6992
|
+
* @example
|
|
6993
|
+
* v.int().coerce() // "5" → 5 (valid); "5.5" → 5.5 (invalid); "abc" → invalid
|
|
6994
|
+
* v.number().coerce() // "5.5" → 5.5 (valid)
|
|
6995
|
+
*/
|
|
6996
|
+
coerce() {
|
|
6997
|
+
return this.addMutator(numericMutator);
|
|
6998
|
+
}
|
|
6999
|
+
/**
|
|
6980
7000
|
* @inheritdoc
|
|
6981
7001
|
*
|
|
6982
7002
|
* Returns `{ type: "number" }` with numeric constraint keywords.
|