Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Required but allow Zero
Message
From
18/10/2010 14:02:35
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01485947
Message ID:
01485968
Views:
56
>>>Hi,
>>>
>>>I've used the Business Layer Generator and it has generated a rule like this for a field:
>>>
>>>
		/// <summary>
>>>		/// Validates the Min Age
>>>		/// </summary>
>>>		public string ValidateMinAge(byte minAge)
>>>		{
>>>			string Msg = null;
>>>			if (mmType.IsEmpty(minAge))
>>>			{
>>>				this.EntityPropertyDisplayName = "Minimum Age";
>>>
>>>				Msg = this.RequiredFieldMessagePrefix + 
>>>					this.EntityPropertyDisplayName + 
>>>					this.RequiredFieldMessageSuffix;
>>>
>>>				AddErrorProviderBrokenRule("MinAge",  Msg);
>>>			}
>>>			return Msg;
>>>		}
>>>
>>>This causes a zero value to be invalid. What do I do to disallow null values but allow a zero value?
>>
>>Frank, that method gets the proposed value passed in and checks if it is empty. You can modify this method anyway you want to check it and set the return message for a broken rule the way you want also. Why is age a byte type?
>Maybe because MinAge is in years and refers to something that won't last for 256 of them :-}

Well, I just learned something and it unfortunately isn't that I won't live that long.
Thanks
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform