Skip to content

Commit

Permalink
remove xml handling
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali214 committed Jun 27, 2024
1 parent 3352fb2 commit a706549
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions packages/schema/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,14 @@ export function validateAndUnmap<T extends Schema<any, any>>(
* @param schema Schema for type
*/
export function validateAndMapXml<T extends Schema<any, any>>(
value: SchemaMappedType<T>,
value: unknown,
schema: T
): ValidationResult<SchemaType<T>> {
const contextCreator = createSchemaContextCreator(
createNewSchemaContext(value, schema.type())
);
const validationResult = schema.validateBeforeMapXml(value, contextCreator);
if (validationResult.length === 0) {
if (isOptionalNullable(schema.type(), value)) {
return { errors: false, result: value };
}
return { errors: false, result: schema.mapXml(value, contextCreator) };
} else {
return { errors: validationResult };
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/types/nullable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function nullable<T, S>(
validateBeforeMapXml: (value, ctxt) =>
value === null ? [] : schema.validateBeforeMapXml(value, ctxt),
mapXml: (value, ctxt) =>
isNullOrMissing(value) ? null : schema.mapXml(value, ctxt),
value === null ? null : schema.mapXml(value, ctxt),
unmapXml: (value, ctxt) =>
value === null ? null : schema.unmapXml(value, ctxt),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/types/optional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function optional<T, S>(
? []
: schema.validateBeforeMapXml(value, ctxt),
mapXml: (value, ctxt) =>
isNullOrMissing(value) ? undefined : schema.mapXml(value, ctxt),
value === null ? undefined : schema.mapXml(value, ctxt),
unmapXml: (value, ctxt) =>
typeof value === 'undefined' ? undefined : schema.unmapXml(value, ctxt),
};
Expand Down

0 comments on commit a706549

Please sign in to comment.