Skip to content

BREAKING: Handle toJSON in JSON validation and sizing#52

Merged
Mrtenz merged 6 commits intomainfrom
mrtenz/validate-to-json
Jan 24, 2023
Merged

BREAKING: Handle toJSON in JSON validation and sizing#52
Mrtenz merged 6 commits intomainfrom
mrtenz/validate-to-json

Conversation

@Mrtenz
Copy link
Copy Markdown
Member

@Mrtenz Mrtenz commented Nov 5, 2022

This modifies the JSON validation function in such a way that:

  • If a value has a toJSON function, it is always called before validating the object.
    • This includes non-object values like strings, numbers, etc.
    • Only the result of toJSON is being sized.
  • The function now includes the value returned by toJSON as result property.

This ensures that we size the same object that would be created by JSON.stringify.

Breaking changes

  • validateJsonAndGetSize now returns an object, rather than a tuple.

@Mrtenz Mrtenz self-assigned this Dec 1, 2022
@Mrtenz Mrtenz force-pushed the mrtenz/validate-to-json branch from c938fdd to 0bb4400 Compare December 2, 2022 11:01
@Mrtenz Mrtenz marked this pull request as ready for review December 2, 2022 11:04
@Mrtenz Mrtenz requested a review from a team as a code owner December 2, 2022 11:04
@Mrtenz Mrtenz force-pushed the mrtenz/validate-to-json branch from 0bb4400 to 3048d68 Compare January 24, 2023 10:21
@Mrtenz Mrtenz changed the title Handle toJSON in JSON validation and sizing BREAKING: Handle toJSON in JSON validation and sizing Jan 24, 2023
@Mrtenz Mrtenz merged commit 01763df into main Jan 24, 2023
@Mrtenz Mrtenz deleted the mrtenz/validate-to-json branch January 24, 2023 13:25
Mrtenz added a commit that referenced this pull request Feb 15, 2023
Mrtenz added a commit that referenced this pull request Feb 15, 2023
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.

4 participants