public DefaultValidation() { IRule trim = new TrimLeadingWhitespace(); PrimitiveRuleBindings.Add(new RuleBinding("*", "FT", trim)); PrimitiveRuleBindings.Add(new RuleBinding("*", "ST", trim)); PrimitiveRuleBindings.Add(new RuleBinding("*", "TX", trim)); IRule size200 = new SizeRule(200); IRule size32000 = new SizeRule(32000); PrimitiveRuleBindings.Add(new RuleBinding("*", "FT", size32000)); PrimitiveRuleBindings.Add(new RuleBinding("*", "ID", size200)); PrimitiveRuleBindings.Add(new RuleBinding("*", "IS", size200)); IRule nonNegativeInteger = new RegexPrimitiveRule("\\d*", ""); PrimitiveRuleBindings.Add(new RuleBinding("*", "SI", nonNegativeInteger)); IRule number = new RegexPrimitiveRule("(\\+|\\-)?\\d*\\.?\\d*", ""); PrimitiveRuleBindings.Add(new RuleBinding("*", "NM", number)); //IRule telephoneNumber = new RegexPrimitiveRule("(\\d{1,2} )?(\\(\\d{3}\\))?\\d{3}-\\d{4}(X\\d{1,5})?(B\\d{1,5})?(C.*)?", "Version 2.4 Section 2.9.45"); //PrimitiveRuleBindings.Add(new RuleBinding("*", "TN", telephoneNumber)); System.String datePattern = "(\\d{4}([01]\\d(\\d{2})?)?)?"; //YYYY[MM[DD]] IRule date = new RegexPrimitiveRule(datePattern, "Version 2.5 Section 2.16.24"); PrimitiveRuleBindings.Add(new RuleBinding("*", "DT", date)); System.String timePattern = "([012]\\d([0-5]\\d([0-5]\\d(\\.\\d(\\d(\\d(\\d)?)?)?)?)?)?)?([\\+\\-]\\d{4})?"; IRule time = new RegexPrimitiveRule(timePattern, "Version 2.5 Section 2.16.79"); PrimitiveRuleBindings.Add(new RuleBinding("*", "TM", time)); System.String datetimePattern = "(\\d{4}([01]\\d(\\d{2}([012]\\d([0-5]\\d([0-5]\\d(\\.\\d(\\d(\\d(\\d)?)?)?)?)?)?)?)?)?)?([\\+\\-]\\d{4})?"; IRule datetime = new RegexPrimitiveRule(datetimePattern, "Version 2.5 Section 2.16.25"); PrimitiveRuleBindings.Add(new RuleBinding("*", "TSComponentOne", datetime)); PrimitiveRuleBindings.Add(new RuleBinding("*", "DTM", datetime)); }
public DefaultValidation() { IRule trim = new TrimLeadingWhitespace(); PrimitiveRuleBindings.Add(new RuleBinding("*", "FT", trim)); PrimitiveRuleBindings.Add(new RuleBinding("*", "ST", trim)); PrimitiveRuleBindings.Add(new RuleBinding("*", "TX", trim)); IRule size200 = new SizeRule(200); IRule size65536 = new SizeRule(65536); PrimitiveRuleBindings.Add(new RuleBinding("*", "FT", size65536)); PrimitiveRuleBindings.Add(new RuleBinding("*", "ID", size200)); PrimitiveRuleBindings.Add(new RuleBinding("*", "IS", size200)); }