fast-xml-validator 1.4.1 → 1.4.3
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/lib/fxv.cjs +1 -1
- package/lib/fxv.d.cts +57 -27
- package/lib/fxv.min.js +1 -1
- package/lib/fxv.min.js.map +1 -1
- package/package.json +4 -2
- package/src/SyntaxValidator.js +27 -4
- package/src/fxv.d.ts +46 -20
- package/src/validators/AttributeStringValidator.js +101 -4
- package/src/validators/DocTypeValidator.js +13 -1
- package/src/validators/XmlDeclarationValidator.js +97 -10
- package/src/DocTypeValidator.js +0 -280
- package/src/validator.js +0 -539
package/lib/fxv.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
type docTypeOptions = {
|
|
2
2
|
/**
|
|
3
|
-
* maximum number of entity present in DOCTYPE
|
|
4
|
-
*
|
|
3
|
+
* maximum number of entity present in DOCTYPE
|
|
4
|
+
*
|
|
5
5
|
* Defaults to `Infinity`
|
|
6
6
|
*/
|
|
7
7
|
maxEntityCount?: number;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* maximum size of each entity present in DOCTYPE
|
|
11
|
-
*
|
|
10
|
+
* maximum size of each entity present in DOCTYPE
|
|
11
|
+
*
|
|
12
12
|
* Defaults to `Infinity`
|
|
13
13
|
*/
|
|
14
14
|
maxEntitySize?: number;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
type invalidCharSequenceOptions = {
|
|
18
18
|
/**
|
|
@@ -38,7 +38,7 @@ type invalidCharSequenceOptions = {
|
|
|
38
38
|
attrLt?: boolean;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
type xmlDeclarationOptions = {
|
|
42
42
|
/**
|
|
43
43
|
* When `false`, the document MUST start with an `<?xml ... ?>` declaration.
|
|
44
44
|
*
|
|
@@ -58,14 +58,14 @@ export type xmlDeclarationOptions = {
|
|
|
58
58
|
type validationOptions = {
|
|
59
59
|
/**
|
|
60
60
|
* Whether to allow attributes without value
|
|
61
|
-
*
|
|
61
|
+
*
|
|
62
62
|
* Defaults to `false`
|
|
63
63
|
*/
|
|
64
64
|
allowBooleanAttributes?: boolean;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* List of tags without closing tags
|
|
68
|
-
*
|
|
68
|
+
*
|
|
69
69
|
* Defaults to `[]`
|
|
70
70
|
*/
|
|
71
71
|
unpairedTags?: string[];
|
|
@@ -78,10 +78,13 @@ type validationOptions = {
|
|
|
78
78
|
/** Controls handling of the `<?xml ... ?>` prolog. */
|
|
79
79
|
xmlDeclaraion?: xmlDeclarationOptions;
|
|
80
80
|
|
|
81
|
+
/** Correctly-spelled alias of `xmlDeclaraion`. */
|
|
82
|
+
xmlDeclaration?: xmlDeclarationOptions;
|
|
83
|
+
|
|
81
84
|
/**
|
|
82
85
|
* Allow more than one root-level element (as if wrapped in a virtual root).
|
|
83
86
|
*
|
|
84
|
-
* Defaults to `
|
|
87
|
+
* Defaults to `true`.
|
|
85
88
|
*/
|
|
86
89
|
multipleRoots?: boolean;
|
|
87
90
|
|
|
@@ -94,19 +97,43 @@ type validationOptions = {
|
|
|
94
97
|
skipTags?: string[];
|
|
95
98
|
};
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Known error codes. The union stays open (`string & {}`) so new codes
|
|
102
|
+
* added in the future don't break consumers' exhaustive checks.
|
|
103
|
+
*/
|
|
104
|
+
type ValidationErrorCode =
|
|
105
|
+
| 'InvalidXml'
|
|
106
|
+
| 'InvalidTag'
|
|
107
|
+
| 'InvalidAttr'
|
|
108
|
+
| 'InvalidChar'
|
|
109
|
+
| 'InvalidDocType'
|
|
110
|
+
| 'IllegalCharacter'
|
|
111
|
+
| 'UnquotedAttributeValue'
|
|
112
|
+
| (string & {});
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Thrown by `SyntaxValidator#validate` on the first well-formedness problem.
|
|
116
|
+
*/
|
|
117
|
+
declare class ValidationError extends Error {
|
|
118
|
+
constructor(message: string, code: ValidationErrorCode, line: number, col: number);
|
|
119
|
+
code: ValidationErrorCode;
|
|
120
|
+
line: number;
|
|
121
|
+
col: number;
|
|
122
|
+
}
|
|
106
123
|
|
|
107
124
|
declare class SyntaxValidator {
|
|
108
125
|
constructor(options?: validationOptions);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @returns `true` when the document is well-formed.
|
|
129
|
+
* @throws {ValidationError} on the first problem found.
|
|
130
|
+
*/
|
|
109
131
|
validate(xmlData: string): true;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @returns `true` when the document is well-formed.
|
|
135
|
+
* @throws {ValidationError} on the first problem found.
|
|
136
|
+
*/
|
|
110
137
|
static validate(xmlData: string, options?: validationOptions): true;
|
|
111
138
|
}
|
|
112
139
|
|
|
@@ -121,7 +148,7 @@ type ValidationFailure = {
|
|
|
121
148
|
value?: string;
|
|
122
149
|
actual?: number | string;
|
|
123
150
|
expected?: number | string;
|
|
124
|
-
}
|
|
151
|
+
};
|
|
125
152
|
|
|
126
153
|
type CustomValidatorFn = (
|
|
127
154
|
value: string,
|
|
@@ -139,7 +166,7 @@ declare class BusinessRulesValidator {
|
|
|
139
166
|
*
|
|
140
167
|
* @example
|
|
141
168
|
* ```ts
|
|
142
|
-
* const validator = new
|
|
169
|
+
* const validator = new BusinessRulesValidator(`
|
|
143
170
|
* <students>
|
|
144
171
|
* <student repeatable minOccurs="1">
|
|
145
172
|
* <email unique="true" nillable="false"></email>
|
|
@@ -177,17 +204,20 @@ declare class BusinessRulesValidator {
|
|
|
177
204
|
validate(xmldata: string): ValidationFailure[];
|
|
178
205
|
}
|
|
179
206
|
|
|
180
|
-
|
|
181
207
|
declare namespace fxv {
|
|
182
208
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
209
|
+
docTypeOptions,
|
|
210
|
+
invalidCharSequenceOptions,
|
|
211
|
+
xmlDeclarationOptions,
|
|
185
212
|
validationOptions,
|
|
213
|
+
ValidationErrorCode,
|
|
214
|
+
ValidationError,
|
|
215
|
+
SyntaxValidator,
|
|
186
216
|
BusinessRulesValidatorOptions,
|
|
187
|
-
|
|
217
|
+
ValidationFailure,
|
|
218
|
+
CustomValidatorFn,
|
|
219
|
+
BusinessRulesValidator,
|
|
188
220
|
}
|
|
189
221
|
}
|
|
190
222
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
export = fxv;
|
|
223
|
+
export = fxv;
|