Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lenient setting with LocalDateDeserializer #129

Closed
cowtowncoder opened this issue Aug 17, 2019 · 1 comment
Closed

Support lenient setting with LocalDateDeserializer #129

cowtowncoder opened this issue Aug 17, 2019 · 1 comment

Comments

@cowtowncoder
Copy link
Member

cowtowncoder commented Aug 17, 2019

(note: follow-up on #106)

It seems like integer values are allowed for LocalDate: this meaning number of days since 1970-01-01 UTC. While this is useful for some users, others may want to prevent that -- this can be supported by using leniency setting (@JsonFormat and/or type/global configOverrides).

Will also benefit from eventual implementation of

FasterXML/jackson-databind#2424

which hopefully makes it in 2.10: it will add a way to define global "strict as baseline" configuration.

@cowtowncoder
Copy link
Member Author

/cc @esHack

Use of leniency property now added for 2.10, deserializer for LocalDate.
Currently it needs to be enabled either on property (add @JsonFormat(lenient = OptBoolean.FALSE)), or via config overrides for all instances of LocalDate:

    ObjectMapper mapper = ...
    mapper.configOverride(LocalDate.class)
            .setFormat(JsonFormat.Value.forLeniency(false));

and this will prevent acceptance of number for LocalDate values.

I will also work on databind issue referenced above to make it easy to declare globally that "strict" mode should be used (unless overridden for specific type or property), which could be even better for many users.

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

No branches or pull requests

1 participant