Ignore Case on Validation

Ask general questions here.
costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Ignore Case on Validation

Post by costamesakid » Mon Jan 31, 2011 11:00 pm

Is there anyway to ignore the case of a string in a validation statement such as the one below?

Code: Select all

		
public static void ValidateSiteEnvironment()
{
Validate.Attribute(repo.FormMain__Site_TN.ListItemSite_Environ_CategoryInfo, "AccessibleValue", Env, Validate.DefaultMessage, false);
}
In this case the AccessibleValue of 'repo.FormMain__Site_TN.ListItemSite_Environ_CategoryInfo' is something like 'LAND TRACK', but the value of 'Env' is 'Land Track'. I realize I can use ToUpper(); on the variable but this will not always work. The variable is derived on one system, is processed through an inter medium, and displayed on another system. I have no way of know what case the AccessibleValue of the object will be after this process. Thanks

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Ignore Case on Validation

Post by slavikf » Tue Feb 01, 2011 12:53 am

I think it can be something like that:
if (repo.FormMain__Site_TN.ListItemSite_Environ_CategoryInfo.Text1001.ToString().ToUpper()!="LAND TRACK")
   Report.Failure (...);

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Ignore Case on Validation

Post by sdaly » Tue Feb 01, 2011 9:21 am

You could also use regex in your rxpaths....

/form/whatever[@text~'(?i:iNcAseSenSITIVE)']