Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.

Fix for Issue #1096 (Model binding errors for invalid dates)#2527

Open
josephdecock wants to merge 1 commit intoNancyFx:masterfrom
josephdecock:master
Open

Fix for Issue #1096 (Model binding errors for invalid dates)#2527
josephdecock wants to merge 1 commit intoNancyFx:masterfrom
josephdecock:master

Conversation

@josephdecock
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the Nancy code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

This is a possible fix for Issue #1096, which is about throwing ModelBindingException for strings that cannot be parsed as dates. That wasn't happening because the FallbackConverter was eating the FormatException thrown by the DateTimeConverter and returning null. My fix is to just rethrow the exception. That might have a broader impact for other types that use the FallbackConverter, but it didn't break any tests, with the exception of Should_ignore_properties_that_cannot_be_converted. I think Should_ignore_properties_that_cannot_be_converted is now invalid because it is asserting that an invalid DateTime should be ignored. Changing that behavior was the whole point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants