@drzl/validation-core 3.10.0 → 3.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/dist/index.cjs +3 -0
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
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
|
+
CODEPOINT_LENGTH: () => CODEPOINT_LENGTH,
|
|
84444
84445
|
COLUMN_FORMATS: () => COLUMN_FORMATS,
|
|
84445
84446
|
DEFAULT_IMPORT_EXTENSION: () => DEFAULT_IMPORT_EXTENSION,
|
|
84446
84447
|
DEFAULT_MODE_PREFIX: () => DEFAULT_MODE_PREFIX,
|
|
@@ -84825,6 +84826,7 @@ var COLUMN_FORMATS = {
|
|
|
84825
84826
|
// probes, `1_000` and `0xDEAD_beef` through to `1__0`, `_1`, `0x` and `1e+`.
|
|
84826
84827
|
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*$"
|
|
84827
84828
|
};
|
|
84829
|
+
var CODEPOINT_LENGTH = "[...v].length";
|
|
84828
84830
|
function isIntegerColumn(c5) {
|
|
84829
84831
|
if (typeof c5.integer === "boolean") return c5.integer;
|
|
84830
84832
|
return c5.dbType === "INTEGER" || c5.min !== void 0 && c5.max !== void 0;
|
|
@@ -84867,6 +84869,7 @@ async function formatCode(code, filePath, fmt) {
|
|
|
84867
84869
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84868
84870
|
0 && (module.exports = {
|
|
84869
84871
|
AFFIX_PROBE_TABLE,
|
|
84872
|
+
CODEPOINT_LENGTH,
|
|
84870
84873
|
COLUMN_FORMATS,
|
|
84871
84874
|
DEFAULT_IMPORT_EXTENSION,
|
|
84872
84875
|
DEFAULT_MODE_PREFIX,
|
package/dist/index.d.cts
CHANGED
|
@@ -405,10 +405,32 @@ declare function isGeneratedColumn(c: Column, _primaryKeyColumns?: string[]): bo
|
|
|
405
405
|
* cidr parses as `inet` and then demands zero host bits, which no regex can state
|
|
406
406
|
*/
|
|
407
407
|
declare const COLUMN_FORMATS: Record<string, string>;
|
|
408
|
+
/**
|
|
409
|
+
* Why a character limit is not `.max(n)`.
|
|
410
|
+
*
|
|
411
|
+
* Postgres and MySQL count `varchar(n)` in **characters**; every JavaScript validator counts
|
|
412
|
+
* `.length`, which is UTF-16 code units. They agree until the text leaves the basic plane, and
|
|
413
|
+
* then they do not: `varchar(10)` accepts ten emoji, and `.max(10)` refuses eight of them.
|
|
414
|
+
*
|
|
415
|
+
* Verified against Postgres through PGlite, for `varchar(10)`:
|
|
416
|
+
*
|
|
417
|
+
* 3 emoji db accepts .max(10) accepts
|
|
418
|
+
* 8 emoji db accepts .max(10) REFUSES
|
|
419
|
+
* 10 emoji db accepts .max(10) REFUSES
|
|
420
|
+
* 11 emoji db refuses .max(10) refuses
|
|
421
|
+
*
|
|
422
|
+
* `[...v].length` counts code points, which is what the database counts, and matches on all four.
|
|
423
|
+
* Refusing a user's emoji is the failure mode this avoids, and it is the same rule applied
|
|
424
|
+
* everywhere else here: never reject what the database accepts.
|
|
425
|
+
*
|
|
426
|
+
* `@sinclair/typebox` and ArkType cannot express it. Both state a length declaratively with no
|
|
427
|
+
* predicate to hook, so they keep the UTF-16 form and are documented as approximate.
|
|
428
|
+
*/
|
|
429
|
+
declare const CODEPOINT_LENGTH = "[...v].length";
|
|
408
430
|
declare function isIntegerColumn(c: Column): boolean;
|
|
409
431
|
declare function insertColumns(table: Table): Column[];
|
|
410
432
|
declare function updateColumns(table: Table): Column[];
|
|
411
433
|
declare function selectColumns(table: Table): Column[];
|
|
412
434
|
declare function formatCode(code: string, filePath: string, fmt?: FormatOptions): Promise<any>;
|
|
413
435
|
|
|
414
|
-
export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, COLUMN_FORMATS, type ColumnCheck, type ColumnSet, 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 RowCheck, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, describeSet, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
|
|
436
|
+
export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, CODEPOINT_LENGTH, COLUMN_FORMATS, type ColumnCheck, type ColumnSet, 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 RowCheck, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, describeSet, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
|
package/dist/index.d.ts
CHANGED
|
@@ -405,10 +405,32 @@ declare function isGeneratedColumn(c: Column, _primaryKeyColumns?: string[]): bo
|
|
|
405
405
|
* cidr parses as `inet` and then demands zero host bits, which no regex can state
|
|
406
406
|
*/
|
|
407
407
|
declare const COLUMN_FORMATS: Record<string, string>;
|
|
408
|
+
/**
|
|
409
|
+
* Why a character limit is not `.max(n)`.
|
|
410
|
+
*
|
|
411
|
+
* Postgres and MySQL count `varchar(n)` in **characters**; every JavaScript validator counts
|
|
412
|
+
* `.length`, which is UTF-16 code units. They agree until the text leaves the basic plane, and
|
|
413
|
+
* then they do not: `varchar(10)` accepts ten emoji, and `.max(10)` refuses eight of them.
|
|
414
|
+
*
|
|
415
|
+
* Verified against Postgres through PGlite, for `varchar(10)`:
|
|
416
|
+
*
|
|
417
|
+
* 3 emoji db accepts .max(10) accepts
|
|
418
|
+
* 8 emoji db accepts .max(10) REFUSES
|
|
419
|
+
* 10 emoji db accepts .max(10) REFUSES
|
|
420
|
+
* 11 emoji db refuses .max(10) refuses
|
|
421
|
+
*
|
|
422
|
+
* `[...v].length` counts code points, which is what the database counts, and matches on all four.
|
|
423
|
+
* Refusing a user's emoji is the failure mode this avoids, and it is the same rule applied
|
|
424
|
+
* everywhere else here: never reject what the database accepts.
|
|
425
|
+
*
|
|
426
|
+
* `@sinclair/typebox` and ArkType cannot express it. Both state a length declaratively with no
|
|
427
|
+
* predicate to hook, so they keep the UTF-16 form and are documented as approximate.
|
|
428
|
+
*/
|
|
429
|
+
declare const CODEPOINT_LENGTH = "[...v].length";
|
|
408
430
|
declare function isIntegerColumn(c: Column): boolean;
|
|
409
431
|
declare function insertColumns(table: Table): Column[];
|
|
410
432
|
declare function updateColumns(table: Table): Column[];
|
|
411
433
|
declare function selectColumns(table: Table): Column[];
|
|
412
434
|
declare function formatCode(code: string, filePath: string, fmt?: FormatOptions): Promise<any>;
|
|
413
435
|
|
|
414
|
-
export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, COLUMN_FORMATS, type ColumnCheck, type ColumnSet, 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 RowCheck, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, describeSet, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
|
|
436
|
+
export { AFFIX_PROBE_TABLE, type AffixIssue, type AffixOptions, type AffixValue, CODEPOINT_LENGTH, COLUMN_FORMATS, type ColumnCheck, type ColumnSet, 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 RowCheck, type Table, type TableCase, type ValidationGenerateOptions, type ValidationLibrary, type ValidationRenderer, applyTableCase, describeSet, formatCode, importSpecifier, insertColumns, isGeneratedColumn, isIntegerColumn, moduleFileName, moduleSpecifier, parseCheck, pascalCase, resolveAffix, resolveConfiguredImport, schemaName, selectColumns, typeName, updateColumns, validateAffix };
|
package/dist/index.js
CHANGED
|
@@ -356,6 +356,7 @@ var COLUMN_FORMATS = {
|
|
|
356
356
|
// probes, `1_000` and `0xDEAD_beef` through to `1__0`, `_1`, `0x` and `1e+`.
|
|
357
357
|
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*$"
|
|
358
358
|
};
|
|
359
|
+
var CODEPOINT_LENGTH = "[...v].length";
|
|
359
360
|
function isIntegerColumn(c) {
|
|
360
361
|
if (typeof c.integer === "boolean") return c.integer;
|
|
361
362
|
return c.dbType === "INTEGER" || c.min !== void 0 && c.max !== void 0;
|
|
@@ -397,6 +398,7 @@ async function formatCode(code, filePath, fmt) {
|
|
|
397
398
|
}
|
|
398
399
|
export {
|
|
399
400
|
AFFIX_PROBE_TABLE,
|
|
401
|
+
CODEPOINT_LENGTH,
|
|
400
402
|
COLUMN_FORMATS,
|
|
401
403
|
DEFAULT_IMPORT_EXTENSION,
|
|
402
404
|
DEFAULT_MODE_PREFIX,
|