Skip to content

Conversation

123NeNaD
Copy link

Checklist

This PR fixes an issue where custom object formats failed during serialization when nested inside a Union type (check #779).

Previously, the fjs_type keyword was used to support JavaScript Date objects, since Ajv does not natively validate them. This PR extends that logic to all objects implementing a .toJSON() method, ensuring they are serialized correctly (for example, MongoDB ObjectId).

Key Points

✅ Extends fjs_type handling beyond Date to any .toJSON()-capable object.
✅ Ensures correct serialization for custom formats like ObjectId.
✅ Backward compatibility is preserved since Date objects already implement .toJSON() (returning an ISO string).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant