<?xml version="1.0" encoding="utf-8" ?>
<!-- Spring Manged Objects -->
<objects xmlns="http://www.springframework.net"
			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xmlns:v="http://www.springframework.net/validation"
			xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd
									  http://www.springframework.net Xsd/spring-validation-1.3.xsd" >

  <description>
	 Spring Validation
	 See this for more info:
	 http://www.springframework.net/doc-latest/reference/html/validation.html
  </description>


  <!--FACILITY RULES-->
  <v:group id="facilityValidationRules" >
	 <!-- Validate custom fields on Agency pages, if applicable -->
	 <v:group id="AgencyCustomFields" when="#this.Facility is T(Sleis.Models.AgencyFacilityModel)">
		<v:ref name ="agencyCustomFieldValidator" context="CustomFields" />
	 </v:group>

	 <!-- Validate custom fields on Public pages, if applicable -->
	 <v:group id="PublicCustomFields" when="#this.Facility is T(Sleis.Models.PublicFacilityModel)">
		<v:ref name ="publicCustomFieldValidator" context="CustomFields" />
	 </v:group>


	 <v:ref name="facGeneralFacilityRules" context="Facility" />
	 <v:ref name="facGeneralFacilityContactRules"/>
	 <v:ref name="facGeneralFacilityAddressRules"/>
  </v:group>


  <!--FACILITY GENERAL-->
  <v:group id="facGeneralFacilityRules">
	 <v:required test="FacName">
		<v:message id="valid.fac.name.required" providers="Facility.FacName" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="FacName" expression=".{0,80}" when="FacName != null">
		<v:message id="valid.fac.name.length" providers="Facility.FacName" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <v:required test="Org" when="#this is T(Sleis.Models.PublicFacilityModel)">
		<v:message id="valid.fac.org.required" providers="Facility.Org" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="Org" expression=".{0,80}" when="Org != null">
		<v:message id="valid.fac.org.length" providers="Facility.Org" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <!--
	 <v:required test="Description">
		<v:message id="valid.fac.desc.required" providers="Facility.Description" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->
	 <v:regex test="Description" expression=".{0,100}" when="Description != null">
		<v:message id="valid.fac.desc.length" providers="Facility.Description" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <v:condition test="FacilityStatus != 'UNK'">
		<v:message id="valid.fac.status.required" providers="Facility.FacilityStatus" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>

	 <v:validator test="FacilityStatusAsOfDate" type="Sleis.Validation.Spring.NullableDateTimeValidator" when="FacilityStatus != 'OP'">
		<v:property name="MessageId" value="valid.fac.statusasofdate.required"/>
		<v:property name="Provider" value="Facility.FacilityStatusAsOfDate"/>
	 </v:validator>

	 <!--
	 <v:required test="FacilityCategory">
		<v:message id="valid.fac.cat.required" providers="Facility.FacilityCategory" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->

	 <v:required test="Naics" when="#this is T(Sleis.Models.PublicFacilityModel)">
		<v:message id="valid.fac.naics.required" providers="Facility.Naics" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>

	 <!--
	 <v:required test="Comment">
		<v:message id="valid.fac.comment.required" providers="Facility.Comment" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->
	 <v:regex test="Comment" expression="^[\s\S]{0,4000}$" when="Comment != null">
		<v:message id="valid.fac.comment.length" providers="Facility.Comment" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <!-- Check for existence of Location object in case it was not created during migration process -->
	 <v:required test="Location">
		<v:message id="valid.fac.loc.required" providers="Facility.Location" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>

	 <v:ref name="facGeneralFacilityLocationRules"/>

  </v:group>


  <!-- CONTACTS -->
  <v:group id="facGeneralFacilityContactRules">
	 <!-- Emissions -->
	 <v:group when="EmissionContact != null">
		<v:required test="EmissionContact.Person.Name" when="#this.Facility is T(Sleis.Models.PublicFacilityModel)">
		  <v:message id="valid.fac.emissioncontact.person.required" providers="EmissionContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:required>
		<!-- Comment out the following required field check if contact type above is required. This requires person nane if contact information entered despite required person check above -->
		<v:required test="EmissionContact.Person.Name" when="EmissionContact.Contacts.Count > 0 and ((EmissionContact.Contacts[0].Value != null and EmissionContact.Contacts[0].Value != '') or (EmissionContact.Contacts[0].Type.ToString() != 'Undefined'))">
		  <v:message id="valid.fac.emissioncontact.person.required.when" providers="EmissionContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:required>
		<v:regex test="EmissionContact.Person.Name"
		  expression=".{1,255}"
		  when="EmissionContact.Person.Name != null">
		  <v:message id="valid.fac.emissioncontact.person.length" providers="EmissionContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:regex>
		<v:validator test="EmissionContact.Contacts" type="Sleis.Validation.Spring.ListValidator">
		  <v:property name="ProviderFormat" value="EmissionContact.Contacts[{0}]." />
		  <v:property name="Validator" ref="facEmissionContactRules" />
		</v:validator>

		<v:condition test="EmissionContact.Contacts.Count > 0" when="#this.Facility is T(Sleis.Models.PublicFacilityModel)">
		  <v:message id="valid.fac.emissioncontact.points.type.required" providers="Type">
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:condition>
	 </v:group>

	 <!-- Permit -->
	 <v:group when="PermitContact != null">
		<!--
		<v:required test="PermitContact.Person.Name">
		  <v:message id="valid.fac.permitcontact.person.required" providers="PermitContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:required>
		-->
		<!-- Comment out the following required field check if contact type above is required. This requires person nane if contact information entered despite required person check above -->
		<v:required test="PermitContact.Person.Name" when="PermitContact.Contacts.Count > 0 and ((PermitContact.Contacts[0].Value != null and PermitContact.Contacts[0].Value != '') or (PermitContact.Contacts[0].Type.ToString() != 'Undefined'))">
		  <v:message id="valid.fac.permitcontact.person.required.when" providers="PermitContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:required>
		<v:regex test="PermitContact.Person.Name"
		  expression=".{1,255}"
		  when="PermitContact.Person.Name != null">
		  <v:message id="valid.fac.permitcontact.person.length" providers="PermitContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:regex>
		<v:validator test="PermitContact.Contacts" type="Sleis.Validation.Spring.ListValidator">
		  <v:property name="ProviderFormat" value="PermitContact.Contacts[{0}]." />
		  <v:property name="Validator" ref="facPermitContactRules" />
		</v:validator>
	 </v:group>

	 <!-- Compliance -->
	 <v:group when="ComplianceContact != null">
		<!--
		<v:required test="ComplianceContact.Person.Name">
		  <v:message id="valid.fac.compliancecontact.person.required" providers="ComplianceContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:required>
		-->
		<!-- Comment out the following required field check if contact type above is required. This requires person nane if contact information entered despite required person check above -->
		<v:required test="ComplianceContact.Person.Name" when="ComplianceContact.Contacts.Count > 0 and ((ComplianceContact.Contacts[0].Value != null and ComplianceContact.Contacts[0].Value != '') or (ComplianceContact.Contacts[0].Type.ToString() != 'Undefined'))">
		  <v:message id="valid.fac.compliancecontact.person.required.when" providers="ComplianceContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:required>
		<v:regex test="ComplianceContact.Person.Name"
			 expression=".{1,255}"
			 when="ComplianceContact.Person.Name != null">
		  <v:message id="valid.fac.compliancecontact.person.length" providers="ComplianceContact.Person.Name" >
			 <v:param value="ValidationContxt"/>
		  </v:message>
		</v:regex>
		<v:validator test="ComplianceContact.Contacts" type="Sleis.Validation.Spring.ListValidator">
		  <v:property name="ProviderFormat" value="ComplianceContact.Contacts[{0}]." />
		  <v:property name="Validator" ref="facComplianceContactRules" />
		</v:validator>
	 </v:group>
  </v:group>


  <v:group id="facEmissionContactRules">
	 <!-- Uncomment the following two conditions if contact method and value are required -->
	 <!--
	 <v:condition test="Type.ToString() != 'Undefined'">
		<v:message id="valid.fac.emissioncontact.points.type.required" providers="Type">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 -->
	 <!--
	 <v:required test="Value">
		<v:message id="valid.fac.emissioncontact.points.value.required" providers="Value">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->
	 <!-- Uncomment the following two conditions if contact method and value are optional, but that if one is entered, the other is required -->
	 <v:condition test="Type.ToString() == 'Undefined'" when ="Value == null">
		<v:message id="valid.fac.emissioncontact.points.value.required" providers="Value">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 <v:condition test="Type.ToString() != 'Undefined'" when ="Value != null">
		<v:message id="valid.fac.emissioncontact.points.type.required" providers="Type">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 <v:regex test="Value"
			  expression=".{0,50}"
			  when="Value != null">
		<v:message id="valid.fac.emissioncontact.points.length" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
				 when="Value != null and Type == 'Email'">
		<v:message id="valid.fac.emissioncontact.points.email.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Phone'">
		<v:message id="valid.fac.emissioncontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Fax'">
		<v:message id="valid.fac.emissioncontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Mobile'">
		<v:message id="valid.fac.emissioncontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
  </v:group>


  <v:group id="facPermitContactRules">
	 <!-- Uncomment the following two conditions if contact method and value are required -->
	 <!--
	 <v:condition test="Type.ToString() != 'Undefined'">
		<v:message id="valid.fac.permitcontact.points.type.required" providers="Type">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 -->
	 <!--
	 <v:required test="Value">
		<v:message id="valid.fac.permitcontact.points.value.required" providers="Value">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->
	 <!-- Uncomment the following two conditions if contact method and value are optional so that if one is entered, the other is required -->
	 <v:condition test="Type.ToString() == 'Undefined'" when ="Value == null">
		<v:message id="valid.fac.permitcontact.points.value.required" providers="Value">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 <v:condition test="Type.ToString() != 'Undefined'" when ="Value != null">
		<v:message id="valid.fac.permitcontact.points.type.required" providers="Type">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 <v:regex test="Value"
				 expression=".{0,50}"
				 when="Value != null">
		<v:message id="valid.fac.permitcontact.points.length" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
				 when="Value != null and Type == 'Email'">
		<v:message id="valid.fac.permitcontact.points.email.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Phone'">
		<v:message id="valid.fac.permitcontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Fax'">
		<v:message id="valid.fac.permitcontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Mobile'">
		<v:message id="valid.fac.permitcontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
  </v:group>


  <v:group id="facComplianceContactRules">
	 <!-- Uncomment the following two conditions if contact method and value are required -->
	 <!--
	 <v:condition test="Type.ToString() != 'Undefined'">
		<v:message id="valid.fac.compliancecontact.points.type.required" providers="Type">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 -->
	 <!--
	 <v:required test="Value">
		<v:message id="valid.fac.compliancecontact.points.value.required" providers="Value">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->
	 <!-- Uncomment the following two conditions if contact method and value are optional so that if one is entered, the other is required -->
	 <v:condition test="Type.ToString() == 'Undefined'" when ="Value == null">
		<v:message id="valid.fac.compliancecontact.points.value.required" providers="Value">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 <v:condition test="Type.ToString() != 'Undefined'" when ="Value != null">
		<v:message id="valid.fac.compliancecontact.points.type.required" providers="Type">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:condition>
	 <v:regex test="Value"
				 expression=".{0,50}"
				 when="Value != null">
		<v:message id="valid.fac.compliancecontact.points.length" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
				 when="Value != null and Type == 'Email'">
		<v:message id="valid.fac.compliancecontact.points.email.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Phone'">
		<v:message id="valid.fac.compliancecontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Fax'">
		<v:message id="valid.fac.compliancecontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
	 <v:regex test="Value"
				 expression="^([\(]{1}[2-9]{1}[0-9]{2}[\)]{1}[ ]{1}[1-9]{1}[0-9]{2}[\-]{1}[0-9]{4})$"
				 when="Value != null and Type == 'Mobile'">
		<v:message id="valid.fac.compliancecontact.points.phone.format" providers="Value" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>
  </v:group>


  <!--ADDRESSES-->
  <v:group id="facGeneralFacilityAddressRules">
	 <!-- Check existence of address objects in case they were not created during migration -->
	 <v:required test="Facility.SiteAddress">
		<v:message id="valid.fac.site.required" providers="Facility.SiteAddress" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:required test="Facility.MailAddress">
		<v:message id="valid.fac.mail.required" providers="Facility.MailAddress" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>

	 <v:ref name="facLocationAddressRules" context="Facility" />
	 <v:ref name="facMailingAddressRules" context="Facility"/>
  </v:group>

  <!-- SITE ADDRESS -->
  <v:group id="facLocationAddressRules" when="SiteAddress != null">
	 <v:required test="SiteAddress.StreetLine1">
		<v:message id="valid.fac.site.addr.street1.required" providers="Facility.SiteAddress.StreetLine1">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="SiteAddress.StreetLine1" expression=".{1,100}" when="SiteAddress.StreetLine1 != null">
		<v:message id="valid.fac.site.street1.length" providers="Facility.SiteAddress.StreetLine1" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <!--
	 v:required test="SiteAddress.StreetLine2">
		<v:message id="valid.fac.site.addr.street2.required" providers="Facility.SiteAddress.StreetLine2">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required
	 -->
	 <v:regex test="SiteAddress.StreetLine2" expression=".{1,100}" when="SiteAddress.StreetLine2 != null">
		<v:message id="valid.fac.site.street2.length" providers="Facility.SiteAddress.StreetLine2" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <v:required test="SiteAddress.City">
		<v:message id="valid.fac.site.addr.city.required" providers="Facility.SiteAddress.City">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="SiteAddress.City" expression=".{1,50}" when="SiteAddress.City != null">
		<v:message id="valid.fac.site.city.length" providers="Facility.SiteAddress.City" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <v:required test="SiteAddress.State">
		<v:message id="valid.fac.site.addr.state.required" providers="Facility.SiteAddress.State">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>

	 <v:required test="SiteAddress.Zip">
		<v:message id="valid.fac.site.addr.zip.required" providers="Facility.SiteAddress.Zip">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="SiteAddress.Zip" expression="^\d{5}(-\d{4})?$" when="SiteAddress.Zip != null">
		<v:message id="valid.fac.site.addr.zip.length" providers="Facility.SiteAddress.Zip" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>
  </v:group>

  <!-- MAIL ADDRESS -->
  <v:group id="facMailingAddressRules" when="MailAddress != null">
	 <v:required test="MailAddress.StreetLine1" when="#this is T(Sleis.Models.PublicFacilityModel)">
		<v:message id="valid.fac.addr.street1.required" providers="Facility.MailAddress.StreetLine1">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="MailAddress.StreetLine1" expression=".{0,100}" when="MailAddress.StreetLine1 != null">
		<v:message id="valid.fac.addr.street1.length" providers="Facility.MailAddress.StreetLine1" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <!--
	 v:required test="MailAddress.StreetLine2">
		<v:message id="valid.fac.addr.street2.required" providers="Facility.MailAddress.StreetLine2">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required
	 -->
	 <v:regex test="MailAddress.StreetLine2" expression=".{0,100}" when="MailAddress.StreetLine2 != null">
		<v:message id="valid.fac.addr.street2.length" providers="Facility.MailAddress.StreetLine2" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <v:required test="MailAddress.City" when="#this is T(Sleis.Models.PublicFacilityModel)">
		<v:message id="valid.fac.addr.city.required" providers="Facility.MailAddress.City">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="MailAddress.City" expression=".{0,50}" when="MailAddress.City != null">
		<v:message id="valid.fac.addr.city.length" providers="Facility.MailAddress.City" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>

	 <v:required test="MailAddress.State" when="#this is T(Sleis.Models.PublicFacilityModel)">
		<v:message id="valid.fac.addr.state.required" providers="Facility.MailAddress.State">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>

	 <v:required test="MailAddress.Zip" when="#this is T(Sleis.Models.PublicFacilityModel)">
		<v:message id="valid.fac.addr.zip.required" providers="Facility.MailAddress.Zip">
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="MailAddress.Zip" expression="^\d{5}(-\d{4})?$" when="MailAddress.Zip != null">
		<v:message id="valid.fac.addr.zip.length" providers="Facility.MailAddress.Zip" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:regex>
  </v:group>


  <!-- LOCATION -->
  <v:group id="facGeneralFacilityLocationRules">

	 <!-- Lat/Long -->
	 <v:required test="Location.Latitude">
		<v:message id="valid.fac.location.lat.required" providers="Facility.Location.Latitude" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <!-- Latitude must be between 17 and 71.5, with minimum of 3 digits past decimal point, and max of 7-->
	 <v:regex test="Location.Latitude"
					  expression="^([1][7-9]|[2-6][0-9]|[7][0-1])\.{1}\d{3,7}$"
					  when="Location.Latitude != null">
		<v:message id="valid.fac.location.lat.format" providers="Facility.Location.Latitude">
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>

	 <v:required test="Location.Longitude">
		<v:message id="valid.fac.location.lng.required" providers="Facility.Location.Longitude" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <!-- Longitude must be between -177 and -64, with minimum of 3 digits past decimal point, and a maximum of 6-->
	 <v:regex test="Location.Longitude"
					  expression="^-([1][7][0-7]|[1][0-6][0-9]|[7-9][0-9]|[6][0-4])\.{1}\d{3,6}$"
					  when="Location.Longitude != null">
		<v:message id="valid.fac.location.lng.format" providers="Facility.Location.Longitude" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>

	 <!-- UTM -->
	 <v:required test="Location.UtmNorth">
		<v:message id="valid.fac.location.utm.north.required" providers="Facility.Location.UtmNorth" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="Location.UtmNorth"
				 expression="^([0-9]*|\d*\.\d{1}?\d*)$"
				 when="Location.UtmNorth != null">
		<v:message id="valid.fac.location.utm.north.format" providers="Facility.Location.UtmNorth" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>

	 <v:required test="Location.UtmEast">
		<v:message id="valid.fac.location.utm.east.required" providers="Facility.Location.UtmEast" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 <v:regex test="Location.UtmEast"
				 expression="^([0-9]*|\d*\.\d{1}?\d*)$"
				 when="Location.UtmEast != null">
		<v:message id="valid.fac.location.utm.east.format" providers="Facility.Location.UtmEast" >
		  <v:param value="ValidationContxt"/>
		</v:message>
		<v:property name="AllowPartialMatching" value="true"/>
	 </v:regex>

	 <v:required test="Location.UtmZone">
		<v:message id="valid.fac.location.utm.zone.required" providers="Facility.Location.UtmZone" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>


	 <!-- OTHER LOCATION INFORMATION-->
	 <!--
	 <v:required test="Location.CollectionMethodCode">
		<v:message id="valid.fac.location.collectionmethodcode.zone.required" providers="Facility.Location.CollectionMethodCode" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->

	 <!--
	 <v:required test="Location.CollectionTime">
		<v:message id="valid.fac.location.collectiontime.zone.required" providers="Facility.Location.CollectionTime" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->

	 <!--
	 <v:required test="Location.ReferencePointCode">
		<v:message id="valid.fac.location.referencepointcode.zone.required" providers="Facility.Location.ReferencePointCode" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->

	 <!--
	 <v:required test="Location.ReferenceSystemCode">
		<v:message id="valid.fac.location.referencesystemcode.zone.required" providers="Facility.Location.ReferenceSystemCode" >
		  <v:param value="ValidationContxt"/>
		</v:message>
	 </v:required>
	 -->
  </v:group>

</objects>