typebox 1.0.77 → 1.0.79

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.
@@ -95,6 +95,8 @@ export function GraphemeCount(value) {
95
95
  // --------------------------------------------------------------------------
96
96
  /** Checks if a string has at least a minimum number of grapheme clusters */
97
97
  export function IsMinLength(value, minLength) {
98
+ if (minLength === 0)
99
+ return true; // 0-length
98
100
  let count = 0;
99
101
  let index = 0;
100
102
  while (index < value.length) {
@@ -125,6 +127,8 @@ export function IsMaxLength(value, maxLength) {
125
127
  // --------------------------------------------------------------------------
126
128
  /** Fast check for minimum grapheme length, falls back to full check if needed */
127
129
  export function IsMinLengthFast(value, minLength) {
130
+ if (minLength === 0)
131
+ return true; // 0-length
128
132
  let index = 0;
129
133
  while (index < value.length) {
130
134
  if (IsGraphemeCodePoint(value.charCodeAt(index))) {
@@ -3,6 +3,13 @@ import type { XStaticSchema } from './schema.mjs';
3
3
  import type { XIf } from '../types/if.mjs';
4
4
  import type { XElse } from '../types/else.mjs';
5
5
  import type { XThen } from '../types/then.mjs';
6
- type XStaticIfReduce<Types extends unknown[], Result extends unknown = never> = (Types extends [infer Left extends unknown, ...infer Right extends unknown[]] ? XStaticIfReduce<Right, Result | Left> : Result);
7
- export type XStaticIf<Stack extends string[], Root extends XSchema, Schema extends XIf, IfSchema extends XSchema, Then extends unknown[] = Schema extends XThen<infer ThenSchema extends XSchema> ? [XStaticSchema<Stack, Root, IfSchema> & XStaticSchema<Stack, Root, ThenSchema>] : [], Else extends unknown[] = Schema extends XElse<infer ElseSchema extends XSchema> ? [...Then, XStaticSchema<Stack, Root, ElseSchema>] : Then, Result extends unknown = Else extends [] ? unknown : XStaticIfReduce<Else>> = Result;
8
- export {};
6
+ export type XStaticIf<Stack extends string[], Root extends XSchema, Schema extends XIf, IfSchema extends XSchema, If extends unknown = XStaticSchema<Stack, Root, IfSchema>, Then extends unknown = Schema extends XThen<infer ThenSchema extends XSchema> ? XStaticSchema<Stack, Root, ThenSchema> : never, Else extends unknown = Schema extends XElse<infer ElseSchema extends XSchema> ? XStaticSchema<Stack, Root, ElseSchema> : never, IsThen extends boolean = Schema extends XThen ? true : false, IsElse extends boolean = Schema extends XElse ? true : false, Result extends unknown = ([
7
+ IsThen,
8
+ IsElse
9
+ ] extends [true, true] ? (If & Then) | Exclude<Else, If> : [
10
+ IsThen,
11
+ IsElse
12
+ ] extends [true, false] ? (If & Then) : [
13
+ IsThen,
14
+ IsElse
15
+ ] extends [false, true] ? Exclude<Else, If> : unknown)> = Result;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.0.77",
4
+ "version": "1.0.79",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"