Bug 17318 - TryValidateProperty returns true when property is nullable and required and the value is null
Summary: TryValidateProperty returns true when property is nullable and required and t...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: General ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-01-19 09:05 UTC by lmarinucci
Modified: 2014-02-11 22:02 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Console app to demonstrate issue. (5.78 KB, text/x-csharp)
2014-01-19 09:05 UTC, lmarinucci
Details
Proposed patch to fix the issue. (6.73 KB, application/octet-stream)
2014-01-19 09:07 UTC, lmarinucci
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description lmarinucci 2014-01-19 09:05:06 UTC
The TryValidateProperty (and ValidateProperty) methods of the System.ComponentModel.DataAnnotation.Validator class do not support nullable values correctly: When a property is nullable and marked as required, then the methods return TRUE even if the value is NULL.

I've attached a console app that demonstrates the issue.
Comment 1 lmarinucci 2014-01-19 09:05:57 UTC
Created attachment 5866 [details]
Console app to demonstrate issue.
Comment 2 lmarinucci 2014-01-19 09:07:08 UTC
Created attachment 5867 [details]
Proposed patch to fix the issue.
Comment 3 Miguel de Icaza [MSFT] 2014-02-11 22:02:37 UTC
Thanks!

Patch applied