@warlock.js/seal 5.10.0 → 5.11.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/llms-full.txt CHANGED
@@ -1553,19 +1553,28 @@ Picking guide is in [`@warlock.js/seal/pick-seal-primitive/SKILL.md`](@warlock.j
1553
1553
 
1554
1554
  ## Strict equality
1555
1555
 
1556
- | Method | Effect |
1557
- |---|---|
1558
- | `.mustBeTrue(msg?)` | strictly `=== true` (rejects `"yes"`, `1`, `"on"`) |
1559
- | `.mustBeFalse(msg?)` | strictly `=== false` |
1556
+ | Method | Effect |
1557
+ | -------------------- | -------------------------------------------------- |
1558
+ | `.mustBeTrue(msg?)` | strictly `=== true` (rejects `"yes"`, `1`, `"on"`) |
1559
+ | `.mustBeFalse(msg?)` | strictly `=== false` |
1560
1560
 
1561
1561
  Use these when the field is a real boolean checkbox value — e.g. "agree to terms" must be exactly `true`, not a truthy string.
1562
1562
 
1563
1563
  ## Form-style coercion — `accepted` / `declined`
1564
1564
 
1565
- The "accepted" rules treat `true`, `"yes"`, `"on"`, `1`, `"1"`, `"true"` as accepted. "Declined" treats their counterparts (`false`, `"no"`, `"off"`, `0`, etc.) as declined. Designed for form inputs where a checkbox/radio arrives as a string.
1566
-
1567
- | Method | Effect |
1568
- |---|---|
1565
+ Calling `.accepted()`/`.declined()` (or any conditional variant) opts `v.boolean()` into
1566
+ form-boolean parsing: a mutator runs before the type rule and converts the accepted set
1567
+ (`1`, `"1"`, `true`, `"true"`, `"yes"`, `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true` and
1568
+ the declined set (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`, `"No"`, `"N"`,
1569
+ `"Off"`) to `false`; any other value passes through unchanged and still fails the type rule.
1570
+ So `v.boolean().accepted()` given `"yes"` is valid **and its output is the real boolean
1571
+ `true`** — not the original string. Designed for form inputs where a checkbox/radio arrives
1572
+ as a string. `v.scalar().accepted()` runs the same accepted/declined rule but keeps the raw
1573
+ value untouched (no boolean type rule, no parsing mutator) — use it when you want the
1574
+ pass/fail check without normalizing the output.
1575
+
1576
+ | Method | Effect |
1577
+ | ----------------- | ---------------------- |
1569
1578
  | `.accepted(msg?)` | value must be accepted |
1570
1579
  | `.declined(msg?)` | value must be declined |
1571
1580
 
@@ -1576,10 +1585,10 @@ string `"true"`, and bare `v.boolean()` is strict by default — it rejects that
1576
1585
  `.coerce()` when a schema validates `request.query`:
1577
1586
 
1578
1587
  ```ts
1579
- v.object({ active: v.boolean().coerce() }) // "true" → true, passes
1588
+ v.object({ active: v.boolean().coerce() }); // "true" → true, passes
1580
1589
  ```
1581
1590
 
1582
- It converts *exactly* `"true"` / `"1"` / `1` → `true` and `"false"` / `"0"` / `0` → `false`.
1591
+ It converts _exactly_ `"true"` / `"1"` / `1` → `true` and `"false"` / `"0"` / `0` → `false`.
1583
1592
  Case-sensitive, no trimming — anything else (`"yes"`, `"on"`, `"TRUE"`, `""`, `2`) passes
1584
1593
  through unchanged and still fails the type rule. That's the line between this and
1585
1594
  `accepted()`/`declined()` below: `.coerce()` is for the narrow, exact query-string
@@ -1589,23 +1598,23 @@ serialization; `accepted()`/`declined()` are for broader form-style truthy strin
1589
1598
 
1590
1599
  ## Conditional variants — accepted
1591
1600
 
1592
- | Method | Args | Effect |
1593
- |---|---|---|
1594
- | `.acceptedIf(field, value, msg?)` | sibling field equals value | must be accepted in that case |
1601
+ | Method | Args | Effect |
1602
+ | ------------------------------------- | -------------------------- | ----------------------------------- |
1603
+ | `.acceptedIf(field, value, msg?)` | sibling field equals value | must be accepted in that case |
1595
1604
  | `.acceptedUnless(field, value, msg?)` | sibling field equals value | must be accepted unless that's true |
1596
- | `.acceptedIfRequired(field, msg?)` | sibling field is required | — |
1597
- | `.acceptedIfPresent(field, msg?)` | sibling field is present | — |
1598
- | `.acceptedWithout(field, msg?)` | sibling field is absent | — |
1605
+ | `.acceptedIfRequired(field, msg?)` | sibling field is required | — |
1606
+ | `.acceptedIfPresent(field, msg?)` | sibling field is present | — |
1607
+ | `.acceptedWithout(field, msg?)` | sibling field is absent | — |
1599
1608
 
1600
1609
  ## Conditional variants — declined
1601
1610
 
1602
- | Method | Args | Effect |
1603
- |---|---|---|
1604
- | `.declinedIf(field, value, msg?)` | sibling field equals value | must be declined in that case |
1611
+ | Method | Args | Effect |
1612
+ | ------------------------------------- | -------------------------- | ----------------------------------- |
1613
+ | `.declinedIf(field, value, msg?)` | sibling field equals value | must be declined in that case |
1605
1614
  | `.declinedUnless(field, value, msg?)` | sibling field equals value | must be declined unless that's true |
1606
- | `.declinedIfRequired(field, msg?)` | — | — |
1607
- | `.declinedIfPresent(field, msg?)` | — | — |
1608
- | `.declinedWithout(field, msg?)` | — | — |
1615
+ | `.declinedIfRequired(field, msg?)` | — | — |
1616
+ | `.declinedIfPresent(field, msg?)` | — | — |
1617
+ | `.declinedWithout(field, msg?)` | — | — |
1609
1618
 
1610
1619
  All conditional variants only run inside `v.object` — sibling resolution silently passes otherwise.
1611
1620
 
@@ -1620,27 +1629,27 @@ All conditional variants only run inside `v.object` — sibling resolution silen
1620
1629
 
1621
1630
  ```ts
1622
1631
  // Strict consent checkbox
1623
- v.boolean().mustBeTrue("You must accept the terms")
1632
+ v.boolean().mustBeTrue("You must accept the terms");
1624
1633
 
1625
1634
  // Form-style "remember me" — accepts "on" / true / 1
1626
- v.boolean().accepted().optional()
1635
+ v.boolean().accepted().optional();
1627
1636
 
1628
1637
  // Cross-field — newsletter must be accepted if subscriptionType = "premium"
1629
1638
  v.object({
1630
1639
  subscriptionType: v.string().oneOf(["free", "premium"]),
1631
1640
  newsletter: v.boolean().acceptedIf("subscriptionType", "premium"),
1632
- })
1641
+ });
1633
1642
 
1634
1643
  // Marketing opt-in — declined unless region is GDPR-exempt
1635
1644
  v.object({
1636
1645
  region: v.string(),
1637
1646
  marketingOptIn: v.boolean().declinedUnless("region", "US"),
1638
- })
1647
+ });
1639
1648
 
1640
1649
  // Query-string flag — ?active=true
1641
1650
  v.object({
1642
1651
  active: v.boolean().coerce(),
1643
- })
1652
+ });
1644
1653
  ```
1645
1654
 
1646
1655
 
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "author": "hassanzohdy",
24
24
  "license": "MIT",
25
- "version": "5.10.0",
25
+ "version": "5.11.0",
26
26
  "main": "./cjs/index.cjs",
27
27
  "module": "./esm/index.mjs",
28
28
  "types": "./esm/index.d.mts",
@@ -13,7 +13,16 @@ Use these when the field is a real boolean checkbox value — e.g. "agree to ter
13
13
 
14
14
  ## Form-style coercion — `accepted` / `declined`
15
15
 
16
- The "accepted" rules treat `true`, `"yes"`, `"on"`, `1`, `"1"`, `"true"` as accepted. "Declined" treats their counterparts (`false`, `"no"`, `"off"`, `0`, etc.) as declined. Designed for form inputs where a checkbox/radio arrives as a string.
16
+ Calling `.accepted()`/`.declined()` (or any conditional variant) opts `v.boolean()` into
17
+ form-boolean parsing: a mutator runs before the type rule and converts the accepted set
18
+ (`1`, `"1"`, `true`, `"true"`, `"yes"`, `"y"`, `"on"`, `"Yes"`, `"Y"`, `"On"`) to `true` and
19
+ the declined set (`0`, `"0"`, `false`, `"false"`, `"no"`, `"n"`, `"off"`, `"No"`, `"N"`,
20
+ `"Off"`) to `false`; any other value passes through unchanged and still fails the type rule.
21
+ So `v.boolean().accepted()` given `"yes"` is valid **and its output is the real boolean
22
+ `true`** — not the original string. Designed for form inputs where a checkbox/radio arrives
23
+ as a string. `v.scalar().accepted()` runs the same accepted/declined rule but keeps the raw
24
+ value untouched (no boolean type rule, no parsing mutator) — use it when you want the
25
+ pass/fail check without normalizing the output.
17
26
 
18
27
  | Method | Effect |
19
28
  | ----------------- | ---------------------- |