const withSnakeCaseKeysPseudo = (self) => {
if (isArray(self)) {
return Schema.Array(
self.elements.map((element) =>
isArray(element) || isStruct(element) || isUnion(element)
? withSnakeCaseKeys(element)
: element,
),
);
}
if (isStruct(self)) {
return Schema.Struct(
Object.fromEntries(
Object.entries(self).map(([key, value]) => [
key,
isArray(value) || isStruct(value) || isUnion(value)
? withSnakeCaseKeys(value)
: Schema.propertySignature(value).pipe(Schema.fromKey(snakeCase(key))),
]),
),
);
}
if (isUnion(self)) {
return Schema.Union(
...self.parts.map((part) =>
isArray(part) || isStruct(part) || isUnion(part)
? withSnakeCaseKeys(part)
: part,
),
);
}
return self;
};
const withSnakeCaseKeysPseudo = (self) => {
if (isArray(self)) {
return Schema.Array(
self.elements.map((element) =>
isArray(element) || isStruct(element) || isUnion(element)
? withSnakeCaseKeys(element)
: element,
),
);
}
if (isStruct(self)) {
return Schema.Struct(
Object.fromEntries(
Object.entries(self).map(([key, value]) => [
key,
isArray(value) || isStruct(value) || isUnion(value)
? withSnakeCaseKeys(value)
: Schema.propertySignature(value).pipe(Schema.fromKey(snakeCase(key))),
]),
),
);
}
if (isUnion(self)) {
return Schema.Union(
...self.parts.map((part) =>
isArray(part) || isStruct(part) || isUnion(part)
? withSnakeCaseKeys(part)
: part,
),
);
}
return self;
};