@drzl/validation-core 3.5.0 → 3.7.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/dist/index.cjs CHANGED
@@ -84441,6 +84441,7 @@ ${codeblock}`, options7);
84441
84441
  var index_exports2 = {};
84442
84442
  __export(index_exports2, {
84443
84443
  AFFIX_PROBE_TABLE: () => AFFIX_PROBE_TABLE,
84444
+ COLUMN_FORMATS: () => COLUMN_FORMATS,
84444
84445
  DEFAULT_IMPORT_EXTENSION: () => DEFAULT_IMPORT_EXTENSION,
84445
84446
  DEFAULT_MODE_PREFIX: () => DEFAULT_MODE_PREFIX,
84446
84447
  DEFAULT_SCHEMA_SUFFIX: () => DEFAULT_SCHEMA_SUFFIX,
@@ -84674,6 +84675,12 @@ function validateAffix(affix, schemaSuffix) {
84674
84675
  function isGeneratedColumn(c5, _primaryKeyColumns = []) {
84675
84676
  return c5.isGenerated;
84676
84677
  }
84678
+ var COLUMN_FORMATS = {
84679
+ // Sign, decimals, exponents, NaN/Infinity, surrounding whitespace, and the underscore digit
84680
+ // separators and 0x/0o/0b integer literals Postgres 16 added. Agrees with Postgres on all 43
84681
+ // probes, `1_000` and `0xDEAD_beef` through to `1__0`, `_1`, `0x` and `1e+`.
84682
+ numeric: "^\\s*([+-]?(0[xX][0-9a-fA-F](_?[0-9a-fA-F])*|0[oO][0-7](_?[0-7])*|0[bB][01](_?[01])*)|[+-]?(\\d(_?\\d)*(\\.(\\d(_?\\d)*)?)?|\\.\\d(_?\\d)*)([eE][+-]?\\d(_?\\d)*)?|[+-]?(NaN|Infinity))\\s*$"
84683
+ };
84677
84684
  function isIntegerColumn(c5) {
84678
84685
  if (typeof c5.integer === "boolean") return c5.integer;
84679
84686
  return c5.dbType === "INTEGER" || c5.min !== void 0 && c5.max !== void 0;
@@ -84716,6 +84723,7 @@ async function formatCode(code, filePath, fmt) {
84716
84723
  // Annotate the CommonJS export names for ESM import in node:
84717
84724
  0 && (module.exports = {
84718
84725
  AFFIX_PROBE_TABLE,
84726
+ COLUMN_FORMATS,
84719
84727
  DEFAULT_IMPORT_EXTENSION,
84720
84728
  DEFAULT_MODE_PREFIX,
84721
84729
  DEFAULT_SCHEMA_SUFFIX,
package/dist/index.d.cts CHANGED
@@ -264,6 +264,23 @@ interface ValidationGenerateOptions {
264
264
  * should be a choice rather than a surprise.
265
265
  */
266
266
  typedJson?: boolean;
267
+ /**
268
+ * Take every column's static type from Drizzle's inference, not just the untyped ones.
269
+ *
270
+ * `typedJson` covers the columns that have no runtime type worth checking. This covers the
271
+ * rest, and exists for `.$type<T>()`, which is a compile-time cast on any column at all:
272
+ * `text().$type<'admin' | 'member'>()` is a `string` to every runtime-derived validator, so
273
+ * `drizzle-orm/zod` and DRZL alike emitted a plain `z.string()` and the narrowing was lost.
274
+ *
275
+ * The runtime schema is untouched. The reference is appended with `.pipe()` rather than
276
+ * replacing anything, so a `varchar(50)` keeps its length check and only its *type* narrows
277
+ * from `string` to the union you declared. Nothing can narrow it at runtime, since the cast
278
+ * leaves no trace there.
279
+ *
280
+ * Implies `typedJson`, since both need the schema imported back. Off by default: it adds a
281
+ * `.pipe()` to every field, which is noise unless you use `.$type<T>()`.
282
+ */
283
+ typedColumns?: boolean;
267
284
  format?: FormatOptions;
268
285
  /**
269
286
  * What every generated file is called after the Drizzle export name, e.g. `.zod.ts`
@@ -321,10 +338,29 @@ declare function isGeneratedColumn(c: Column, _primaryKeyColumns?: string[]): bo
321
338
  * was true only while integers were the sole bounded type, so it is kept strictly for an
322
339
  * analysis produced before `Column.integer` existed, and never consulted when the flag is set.
323
340
  */
341
+ /**
342
+ * Patterns for string columns whose contents the database constrains.
343
+ *
344
+ * Every entry was validated against Postgres through PGlite rather than reasoned about: the
345
+ * pattern and the database agree on a pool built to include the awkward *valid* forms, because
346
+ * the real hazard is over-rejection. A check that turns away something Postgres accepts breaks
347
+ * working code, which is worse than the bare `string` it replaces.
348
+ *
349
+ * That is why there is exactly one entry. Candidates for `date`, `timestamp`, `time`, `interval`,
350
+ * `inet`, `cidr` and `macaddr` were all built and all rejected, each by a value Postgres accepts
351
+ * and the pattern did not:
352
+ *
353
+ * date `today`, `January 8, 1999`, `20200101`, `01/02/2020`, `infinity`
354
+ * time `allballs`, `12:00:00+02`
355
+ * macaddr `2020-01-01`, which Postgres pads into `20:20:00:01:00:01`
356
+ * inet `10.1/16`, `::ffff:1.2.3.4`
357
+ * cidr parses as `inet` and then demands zero host bits, which no regex can state
358
+ */
359
+ declare const COLUMN_FORMATS: Record<string, string>;
324
360
  declare function isIntegerColumn(c: Column): boolean;
325
361
  declare function insertColumns(table: Table): Column[];
326
362
  declare function updateColumns(table: Table): Column[];
327
363
  declare function selectColumns(table: Table): Column[];
328
364
  declare function formatCode(code: string, filePath: string, fmt?: FormatOptions): Promise<any>;
329
365
 
330
- export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, type ColumnCheck, DEFAULT_IMPORT_EXTENSION, DEFAULT_MODE_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_TYPE_SUFFIX, type FormatOptions, IMPORT_EXTENSIONS, type ImportExtension, NAME_MODES, type NameMode, type ParsedCheck, type ResolvedAffix, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
366
+ export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, COLUMN_FORMATS, type ColumnCheck, DEFAULT_IMPORT_EXTENSION, DEFAULT_MODE_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_TYPE_SUFFIX, type FormatOptions, IMPORT_EXTENSIONS, type ImportExtension, NAME_MODES, type NameMode, type ParsedCheck, type ResolvedAffix, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
package/dist/index.d.ts CHANGED
@@ -264,6 +264,23 @@ interface ValidationGenerateOptions {
264
264
  * should be a choice rather than a surprise.
265
265
  */
266
266
  typedJson?: boolean;
267
+ /**
268
+ * Take every column's static type from Drizzle's inference, not just the untyped ones.
269
+ *
270
+ * `typedJson` covers the columns that have no runtime type worth checking. This covers the
271
+ * rest, and exists for `.$type<T>()`, which is a compile-time cast on any column at all:
272
+ * `text().$type<'admin' | 'member'>()` is a `string` to every runtime-derived validator, so
273
+ * `drizzle-orm/zod` and DRZL alike emitted a plain `z.string()` and the narrowing was lost.
274
+ *
275
+ * The runtime schema is untouched. The reference is appended with `.pipe()` rather than
276
+ * replacing anything, so a `varchar(50)` keeps its length check and only its *type* narrows
277
+ * from `string` to the union you declared. Nothing can narrow it at runtime, since the cast
278
+ * leaves no trace there.
279
+ *
280
+ * Implies `typedJson`, since both need the schema imported back. Off by default: it adds a
281
+ * `.pipe()` to every field, which is noise unless you use `.$type<T>()`.
282
+ */
283
+ typedColumns?: boolean;
267
284
  format?: FormatOptions;
268
285
  /**
269
286
  * What every generated file is called after the Drizzle export name, e.g. `.zod.ts`
@@ -321,10 +338,29 @@ declare function isGeneratedColumn(c: Column, _primaryKeyColumns?: string[]): bo
321
338
  * was true only while integers were the sole bounded type, so it is kept strictly for an
322
339
  * analysis produced before `Column.integer` existed, and never consulted when the flag is set.
323
340
  */
341
+ /**
342
+ * Patterns for string columns whose contents the database constrains.
343
+ *
344
+ * Every entry was validated against Postgres through PGlite rather than reasoned about: the
345
+ * pattern and the database agree on a pool built to include the awkward *valid* forms, because
346
+ * the real hazard is over-rejection. A check that turns away something Postgres accepts breaks
347
+ * working code, which is worse than the bare `string` it replaces.
348
+ *
349
+ * That is why there is exactly one entry. Candidates for `date`, `timestamp`, `time`, `interval`,
350
+ * `inet`, `cidr` and `macaddr` were all built and all rejected, each by a value Postgres accepts
351
+ * and the pattern did not:
352
+ *
353
+ * date `today`, `January 8, 1999`, `20200101`, `01/02/2020`, `infinity`
354
+ * time `allballs`, `12:00:00+02`
355
+ * macaddr `2020-01-01`, which Postgres pads into `20:20:00:01:00:01`
356
+ * inet `10.1/16`, `::ffff:1.2.3.4`
357
+ * cidr parses as `inet` and then demands zero host bits, which no regex can state
358
+ */
359
+ declare const COLUMN_FORMATS: Record<string, string>;
324
360
  declare function isIntegerColumn(c: Column): boolean;
325
361
  declare function insertColumns(table: Table): Column[];
326
362
  declare function updateColumns(table: Table): Column[];
327
363
  declare function selectColumns(table: Table): Column[];
328
364
  declare function formatCode(code: string, filePath: string, fmt?: FormatOptions): Promise<any>;
329
365
 
330
- export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, type ColumnCheck, DEFAULT_IMPORT_EXTENSION, DEFAULT_MODE_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_TYPE_SUFFIX, type FormatOptions, IMPORT_EXTENSIONS, type ImportExtension, NAME_MODES, type NameMode, type ParsedCheck, type ResolvedAffix, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
366
+ export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, COLUMN_FORMATS, type ColumnCheck, DEFAULT_IMPORT_EXTENSION, DEFAULT_MODE_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_TYPE_SUFFIX, type FormatOptions, IMPORT_EXTENSIONS, type ImportExtension, NAME_MODES, type NameMode, type ParsedCheck, type ResolvedAffix, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
package/dist/index.js CHANGED
@@ -207,6 +207,12 @@ function validateAffix(affix, schemaSuffix) {
207
207
  function isGeneratedColumn(c, _primaryKeyColumns = []) {
208
208
  return c.isGenerated;
209
209
  }
210
+ var COLUMN_FORMATS = {
211
+ // Sign, decimals, exponents, NaN/Infinity, surrounding whitespace, and the underscore digit
212
+ // separators and 0x/0o/0b integer literals Postgres 16 added. Agrees with Postgres on all 43
213
+ // probes, `1_000` and `0xDEAD_beef` through to `1__0`, `_1`, `0x` and `1e+`.
214
+ numeric: "^\\s*([+-]?(0[xX][0-9a-fA-F](_?[0-9a-fA-F])*|0[oO][0-7](_?[0-7])*|0[bB][01](_?[01])*)|[+-]?(\\d(_?\\d)*(\\.(\\d(_?\\d)*)?)?|\\.\\d(_?\\d)*)([eE][+-]?\\d(_?\\d)*)?|[+-]?(NaN|Infinity))\\s*$"
215
+ };
210
216
  function isIntegerColumn(c) {
211
217
  if (typeof c.integer === "boolean") return c.integer;
212
218
  return c.dbType === "INTEGER" || c.min !== void 0 && c.max !== void 0;
@@ -248,6 +254,7 @@ async function formatCode(code, filePath, fmt) {
248
254
  }
249
255
  export {
250
256
  AFFIX_PROBE_TABLE,
257
+ COLUMN_FORMATS,
251
258
  DEFAULT_IMPORT_EXTENSION,
252
259
  DEFAULT_MODE_PREFIX,
253
260
  DEFAULT_SCHEMA_SUFFIX,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drzl/validation-core",
3
- "version": "3.5.0",
3
+ "version": "3.7.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "sideEffects": false,
13
13
  "dependencies": {
14
- "@drzl/analyzer": "^1.8.0"
14
+ "@drzl/analyzer": "^1.9.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "tsup": "^8.5.1",