# Customer validation rules
# =========================
#
# The rules have option names like:
# customer_validation.<RuleName>.<RuleSetNo>.<CountryOption>.<ProductGroupOption>.<ProductOption>
#
# Example:
# customer_validation.zip.1.se.default.default
#
# The last three can be "default", trailing defaults can be skipped, but
# all rules for a field have to have the same number of parts in the option name
#
# <CountryOption> should correspond to the country codes as used in Billing API.
#
# <ProductGroupOption> and <ProductOption> should correspond to the HostingProduct configuration
# attributes "productCategory" and "articalNumber" respectively.
# 
# Rule Sets and Specificity
# -------------------------
#
# The numbers in option names represent a rule set. Only the most specific applicable 
# rule in a rule set will be used for validation. If multiple rules should all be applicable they
# must be placed in different rule sets.
#
# Rule specificity is based firstly on the number of non-defaults and secondly on the following 
# order: country is more specific than product, which in turn is more specific than product group, 
# i.e. country > product > product group.
# 
# If there is more than one applicable rule of the same specificity in a rule set the rule that will 
# be selected is undefined.
#
# If multiple applicable rules should be applied, they must be put in different rule sets. 
# Logically we have something like this Valid = (RuleSet1.RuleA || RuleSet1.RuleB) && (RuleSet2.RuleA || RuleSet2.RuleB) && ...
# E.g. DMN-SE and DMN-NU products both have the same requirements regarding identity_number, but the rules are 
# independent of each other, so they are placed in different rule sets.
#
#
# Custom Fields
# ---------------
# 
# Custom fields part allows specification of additional contact fields that will be requested and passed to domain contact 
# when domains are ordered or contacts are assigned to them.
#
# The rules have option names like:
# custom_fields.<RuleSetNo>.<FieldName>.<CountryOption>.<ProductGroupOption>.<ProductOption>
#
# Example:
# custom_fields.1.nexus_app_purpose.default.default.DMN-US				regexp.required			.+
#
# Only regexp rule types are supported for custom fields.
#
#
# Required Fields
# ---------------
# 
# Normally the decision whether a field should be considered required or not is defered to the place where
# the validation is initiated, e.g. by setting AtomiaRequired or Required attributes on an ASP.NET MVC model property. 
#
# This means that empty values are always considered valid regardless of the rule value.
# 
# In cases where there is a hard requirement, i.e. the value MUST be supplied, it is possible to override the 
# default behavior by putting the rule type as 'regexp.required' or 'javascript.required'.
#
# Please note that overriding the default behavior and make a hard required field should only need to be done very rarely.
# 
# Examples:
# * It is not possible to register a .se domain without supplying a Swedish corporate or personal identity number. This 
#   is a hard requirement.
# * A Swedish zip code always should consist of 5 digits. There could be many cases though where a zip code is not required,
#   but iff one is supplied for a Swedish address, it should be validated for 5 digits. This is NOT a hard requirement.
#
#
# Replace value
# ---------------
# 
# It is possible to define replacement string for regexp rules. If defined, this replacement string will be used together
# with validation regular expression in Regex.Replace(input, pattern, replacement) method where input is field value, 
# patter is validation rule value and replacement is replace string.
# 
# Example:
# * customer_validation.zip.1.se		regexp		^([0-9]{3})\s?([0-9]{2})$		(replace: $1$2)
# In this example, replace string is $1$2 which in this case will match first and second group from field value and join 
# them together (i.e. string 123 45 will be replaced with 12345).

# Option name															# Type					# Value															# Replace regexp (optional)

# Names etc.
customer_validation.first_name.1										regexp					.+
customer_validation.last_name.1											regexp					.+
customer_validation.company_name.1										regexp					.+
customer_validation.address.1											regexp					.+
customer_validation.city.1												regexp					.+



# Email address
customer_validation.email.1												regexp					^\S+@\S+$



# Zip, default
customer_validation.zip.1.default										regexp					^[0-9]{3,10}$

# Zip, EU
customer_validation.zip.1.at											regexp					^[0-9]{4}$
customer_validation.zip.1.be											regexp					^[0-9]{4}$
customer_validation.zip.1.bg											regexp					^[0-9]{4}$
customer_validation.zip.1.cy											regexp					^[0-9]{4}$
customer_validation.zip.1.cz											regexp					^[0-9]{3}\s?[0-9]{2}$
customer_validation.zip.1.de											regexp					^[0-9]{5}$
customer_validation.zip.1.ee											regexp					^[0-9]{5}$
customer_validation.zip.1.es											regexp					^[0-9]{5}$
customer_validation.zip.1.fi											regexp					^[0-9]{5}$
customer_validation.zip.1.fr											regexp					^[0-9]{5}$
customer_validation.zip.1.gr											regexp					^[0-9]{3}\s?[0-9]{2}$
customer_validation.zip.1.hr											regexp					^[0-9]{5}$
customer_validation.zip.1.hu											regexp					^[0-9]{4}$
customer_validation.zip.1.ie											regexp					.*
customer_validation.zip.1.it											regexp					^[0-9]{5}$
customer_validation.zip.1.lt											regexp					^(LT-|lt-)?[0-9]{5}$
customer_validation.zip.1.lu											regexp					^[0-9]{5}$
customer_validation.zip.1.lv											regexp					^(LV-|lv-)[0-9]{4}$
customer_validation.zip.1.mt											regexp					^[a-zA-Z]{3}\s?[0-9]{4}$
customer_validation.zip.1.nl											regexp					^[1-9][0-9]{3}(\s)?(?!SS|ss|SA|sa|SD|sd)[a-zA-Z]{2}$
customer_validation.zip.1.pl											regexp					^[0-9]{2}-?[0-9]{3}$
customer_validation.zip.1.pt											regexp					^[0-9]{4}[\-\s]?[0-9]{3}$
customer_validation.zip.1.ro											regexp					^[0-9]{6}$
customer_validation.zip.1.se											regexp					^([0-9]{3})\s?([0-9]{2})$										(replace: $1$2)
customer_validation.zip.1.si											regexp					^(SI-|si-)?[0-9]{4}$
customer_validation.zip.1.sk											regexp					^[0-9]{3}\s?[0-9]{2}$

# ZIP, Denmark. Three digit Faroe Island codes purposefully not included.
customer_validation.zip.1.dk											regexp					^(((DK|dk)(-| |))?\d{4})$

# ZIP, UK
# Based on the rules from Royal Mail Programmers' Guide Edition 7, version 5.0 (p. 17-18)
customer_validation.zip.1.gb											regexp					^(GIR 0AA)|((([A-PR-UWYZ][0-9]{1,2})|([A-PR-UWYZ][A-HK-Y][0-9]{1,2})|([A-PR-UWYZ][0-9][A-HJKPSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][A-Z])) [0-9][ABD-HJLNP-UWXYZ]{2})$

# Zip, Norway, Argentina, United States, Canada and Bermuda
customer_validation.zip.1.no											regexp					^[0-9]{4}$
customer_validation.zip.1.ar											regexp					^([a-zA-Z]{1})?[0-9]{4}([a-zA-Z]{3})?$
customer_validation.zip.1.us											regexp					^[0-9]{5}(?:-[0-9]{4})?$
customer_validation.zip.1.ca											regexp					^(?!.*[DFIOQU])[A-VXY][0-9][A-Z]?[0-9][A-Z][0-9]$
customer_validation.zip.1.bm											regexp					^[a-zA-Z]{2} (([a-zA-Z]{2}|[0-9]{2}))$


# Identity number, default
customer_validation.identity_number.1.default							regexp					.+

# Identity number, country specific
customer_validation.identity_number.1.se								regexp					^[0-9]{6}\-[0-9]{4}$
customer_validation.identity_number.1.no								regexp					^[0-9]{6}\-?[0-9]{5}$

# Identity number, requirement for .se
customer_validation.identity_number.2.se.default.DMN-SE					regexp.required			^[0-9]{6}\-[0-9]{4}$

# Identity number, requirement for .nu
customer_validation.identity_number.3.se.default.DMN-NU					regexp.required			^[0-9]{6}\-[0-9]{4}$



# VAT, default 
customer_validation.vat_number.1.default								regexp					.+

# VAT, EU (removes '-' and '.', country prefix optional)
# Reference: http://ec.europa.eu/taxation_customs/vies/faqvies.do#item_11
customer_validation.vat_number.1.at										javascript				function (val) { return /^(AT)?U[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.be										javascript				function (val) { return /^(BE)?0?[0-9]{9}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.bg										javascript				function (val) { return /^(BG)?[0-9]{9,10}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.cy										javascript				function (val) { return /^(CY)?[0-9]{8}[A-Z]$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.cz										javascript				function (val) { return /^(CZ)?[0-9]{8,10}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.de										javascript				function (val) { return /^(DE)?[0-9]{9}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.dk										javascript				function (val) { return /^(DK)?[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.ee										javascript				function (val) { return /^(EE)?[0-9]{9}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.es										javascript				function (val) { return /^(ES)?[0-9A-Z][0-9]{7}[0-9A-Z]$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.fi										javascript				function (val) { return /^(FI)?[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.fr										javascript				function (val) { return /^(FR)?[0-9A-Z]{2}[0-9]{9}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.gb										javascript				function (val) { return /^(GB)?([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.gr										javascript				function (val) { return /^(EL|GR)?[0-9]{9}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.hr										javascript				function (val) { return /^(HR)?[0-9]{11}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.hu										javascript				function (val) { return /^(HU)?[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.ie										javascript				function (val) { return /^(IE)?(([0-9]{7}[A-Z]{1,2})|([0-9][A-Z0-9+*][0-9]{5}[A-Z]))$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.it										javascript				function (val) { return /^(IT)?[0-9]{11}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.lt										javascript				function (val) { return /^(LT)?([0-9]{9}|[0-9]{12})$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.lu										javascript				function (val) { return /^(LU)?[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.lv										javascript				function (val) { return /^(LV)?[0-9]{11}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.mt										javascript				function (val) { return /^(MT)?[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.nl										javascript				function (val) { return /^(NL)?[0-9]{9}B[0-9]{2}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.pl										javascript				function (val) { return /^(PL)?[0-9]{10}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.pt										javascript				function (val) { return /^(PT)?[0-9]{9}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.ro										javascript				function (val) { return /^(RO)?[0-9]{2,10}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.se										javascript				function (val) { return /^(SE)?[0-9]{12}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.si										javascript				function (val) { return /^(SI)?[0-9]{8}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.1.sk										javascript				function (val) { return /^(SK)?[0-9]{10}$/.test(val.replace(/[-.?]/, "")); }

# VAT, requirement for .se, non-Swedish entities
# Does not apply to Sweden so override with more specific rule.
customer_validation.vat_number.2.se.default.DMN-SE						javascript				function (val) { return /^(SE)?[0-9]{12}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.2.default.default.DMN-SE					regexp.required			.+

# VAT, requirement for .nu, non-Swedish entities
# Does not apply to Sweden so override with more specific rule.
customer_validation.vat_number.3.se.default.DMN-NU						javascript				function (val) { return /^(SE)?[0-9]{12}$/.test(val.replace(/[-.?]/, "")); }
customer_validation.vat_number.3.default.default.DMN-NU					regexp.required			.+



# Country codes
customer_validation.country.1.default									regexp					^[a-zA-Z]{2}$



# Phone, mobile and fax per country
customer_validation.phone.1.default										regexp					^\+?([-.,/()\s]?[0-9]){6,14}[-.,/()\s]?[0-9]$
customer_validation.mobile.1.default									regexp					^\+?([-.,/()\s]?[0-9]){6,14}[-.,/()\s]?[0-9]$
customer_validation.fax.1.default										regexp					^\+?([-.,/()\s]?[0-9]){6,14}[-.,/()\s]?[0-9]$



# Custom fields
# custom_fields.<RuleSetNo>.<FieldName>.<CountryOption>.<ProductGroupOption>.<ProductOption>
custom_fields.1.nexus_app_purpose.default.default.DMN-US				regexp.required			^P[1-5]$
custom_fields.1.nexus_category.default.default.DMN-US					regexp.required			^C(11|12|21|31|32)$

custom_fields.1.test_field1.default.default.DMN-TTT						regexp					^([0-9]{3})\s?([0-9]{2})$
custom_fields.2.test_field1.se.default.DMN-TTT							regexp.required			^([0-9]{3})\s?([0-9]{2})$										(replace: $1$2)



# Password requirements
# =====================
#
# The password requirements rules have option names like:
# password_requirements.<RuleName>.<Application>
#
# <Application> can be set to default (all applications), hcp (HostingControlPanel), bcup (BillingCustomerPanel), pop (PublicOrderPage) or admin (AdminPanel).
#
# Examples:
#   password_requirements.email_account.default
#   password_requirements.email_account.hcp
#
# All password requirements rules must have type regexp.
# 

# Email account
password_requirements.email_account.default								regexp					^.{8,20}$

# Note: If using TNAPI, the following rule should be used:
# password_requirements.email_account.default							regexp					^(?=.{6,8}$)(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*


# FTP account
password_requirements.ftp_account.default								regexp					^.{8,20}$


# SSH account
password_requirements.ssh_account.default								regexp					(?=^.{8,255}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*


# MySQL user
password_requirements.mysql_user.default								regexp					^.{8,20}$


# MSSQL user
password_requirements.mssql_user.default								regexp					^(?=.{8,20}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*


# Website password protection
password_requirements.website_passwordprotection.default				regexp					^.{8,20}$


# Exchange mailbox
password_requirements.exchange_mailbox.default							regexp					^.{8,20}$


#########


# TEST, internal type used for testing.
password_requirements.internal_test.default								regexp					^default$
password_requirements.internal_test.hcp									regexp					^hcp$