ata-validator 0.4.3 → 0.4.4
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/include/ata.h +2 -2
- package/index.d.ts +35 -2
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/ata-validator.node +0 -0
package/include/ata.h
CHANGED
|
@@ -12,10 +12,10 @@ namespace ata {
|
|
|
12
12
|
|
|
13
13
|
inline constexpr uint32_t VERSION_MAJOR = 0;
|
|
14
14
|
inline constexpr uint32_t VERSION_MINOR = 4;
|
|
15
|
-
inline constexpr uint32_t VERSION_REVISION =
|
|
15
|
+
inline constexpr uint32_t VERSION_REVISION = 3;
|
|
16
16
|
|
|
17
17
|
inline constexpr std::string_view version() noexcept {
|
|
18
|
-
return "0.4.
|
|
18
|
+
return "0.4.3";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
enum class error_code : uint8_t {
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface ValidationError {
|
|
2
|
-
code:
|
|
2
|
+
code: string;
|
|
3
3
|
path: string;
|
|
4
4
|
message: string;
|
|
5
5
|
}
|
|
@@ -9,6 +9,11 @@ export interface ValidationResult {
|
|
|
9
9
|
errors: ValidationError[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface ValidatorOptions {
|
|
13
|
+
coerceTypes?: boolean;
|
|
14
|
+
removeAdditional?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export interface StandardSchemaV1Props {
|
|
13
18
|
version: 1;
|
|
14
19
|
vendor: "ata-validator";
|
|
@@ -20,11 +25,35 @@ export interface StandardSchemaV1Props {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export class Validator {
|
|
23
|
-
constructor(schema: object | string);
|
|
28
|
+
constructor(schema: object | string, options?: ValidatorOptions);
|
|
29
|
+
|
|
30
|
+
/** Validate data — returns result with errors. Applies defaults, coerceTypes, removeAdditional. */
|
|
24
31
|
validate(data: unknown): ValidationResult;
|
|
32
|
+
|
|
33
|
+
/** Fast boolean check — JS codegen, no error collection */
|
|
34
|
+
isValidObject(data: unknown): boolean;
|
|
35
|
+
|
|
36
|
+
/** Validate JSON string — simdjson fast path for large docs */
|
|
25
37
|
validateJSON(jsonString: string): ValidationResult;
|
|
38
|
+
|
|
39
|
+
/** Fast boolean check for JSON string */
|
|
26
40
|
isValidJSON(jsonString: string): boolean;
|
|
27
41
|
|
|
42
|
+
/** Validate Buffer/Uint8Array — raw NAPI fast path */
|
|
43
|
+
isValid(input: Buffer | Uint8Array): boolean;
|
|
44
|
+
|
|
45
|
+
/** Zero-copy validation with pre-padded buffer */
|
|
46
|
+
isValidPrepadded(paddedBuffer: Buffer, jsonLength: number): boolean;
|
|
47
|
+
|
|
48
|
+
/** Multi-core parallel NDJSON validation — returns boolean per line */
|
|
49
|
+
isValidParallel(ndjsonBuffer: Buffer): boolean[];
|
|
50
|
+
|
|
51
|
+
/** Multi-core parallel NDJSON count — returns number of valid items */
|
|
52
|
+
countValid(ndjsonBuffer: Buffer): number;
|
|
53
|
+
|
|
54
|
+
/** Single-thread NDJSON batch validation */
|
|
55
|
+
isValidNDJSON(ndjsonBuffer: Buffer): boolean[];
|
|
56
|
+
|
|
28
57
|
/** Standard Schema V1 interface — compatible with Fastify, tRPC, TanStack, etc. */
|
|
29
58
|
readonly "~standard": StandardSchemaV1Props;
|
|
30
59
|
}
|
|
@@ -35,3 +64,7 @@ export function validate(
|
|
|
35
64
|
): ValidationResult;
|
|
36
65
|
|
|
37
66
|
export function version(): string;
|
|
67
|
+
|
|
68
|
+
export function createPaddedBuffer(jsonStr: string): { buffer: Buffer; length: number };
|
|
69
|
+
|
|
70
|
+
export const SIMDJSON_PADDING: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ata-validator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Ultra-fast JSON Schema validator. Beats ajv on every valid-path benchmark: 1.1x–2.7x faster validate(obj), 151x faster compilation, 5.9x faster parallel batch. Speculative validation with V8-optimized JS codegen, simdjson, multi-core. Standard Schema V1 compatible.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
Binary file
|