Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        /// <summary>   Initializes a new instance of the DefaultValidation class. </summary>
        public DefaultValidation()
        {
            IRule trim = new TrimLeadingWhitespace();

            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "FT", trim));
            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "ST", trim));
            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "TX", trim));

            IRule size200   = new SizeRule(200);
            IRule size32000 = new SizeRule(32000);

            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "FT", size32000));
            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "ID", size200));
            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "IS", size200));

            IRule nonNegativeInteger = new RegexPrimitiveRule("\\d*", "");

            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "SI", nonNegativeInteger));

            IRule number = new RegexPrimitiveRule("(\\+|\\-)?\\d*\\.?\\d*", "");

            this.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");

            this.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");

            this.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");

            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "TSComponentOne", datetime));
            this.PrimitiveRuleBindings.Add(new RuleBinding("*", "DTM", datetime));
        }