DataAnnotationsExtensions icon indicating copy to clipboard operation
DataAnnotationsExtensions copied to clipboard

Added NotNullOrZero Attribute + test + website modifications

Open Edddy opened this issue 12 years ago • 2 comments

This attribute is useful when Required is not enough because the value can't be zero either (Great for IDs)

Edddy avatar Aug 17 '12 18:08 Edddy

Unfortunately this validator won't work client-side, so I'm not going to merge quite yet. Maybe you can create a client attribute adapter that uses both a "required" rule and a "non-zero" rule (currently a non-zero rule doesn't exist)? Also did you consider just doing something like [Required] along with [Min(1)]?

srkirkland avatar Sep 11 '12 05:09 srkirkland

Yes, I currently use Min(1) but have to change the message everytime (want to avoid) and it's not semantic enough (want to avoid).

Will work on the client side and let you know.

Edddy avatar Sep 11 '12 12:09 Edddy