Esempio n. 1
0
        private void SetValueCounts()
        {
            #region ArresteeArmedWith can only have one value when 01 is used

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "arresteeArmedWith");

            ValidationMessage = new ValidationMessage(string.Format("{0} can only have one value when 01 is used", TargetFieldLabel), "arresteeArmedWith");

            TargetField = new ValidationField
            {
                FieldPath   = "arresteeArmedWith",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Multiselect,
            };

            NibrsValidationRules.Add(new Validation(new Guid("CD8D0BD3-F4D4-4728-942A-4131D297D680"), ValidationMessage, TargetField)
                                     .ValueCount("1")
                                     .WithConditions()
                                     .Contains(TargetField, new List <string> {
                "01"
            })
                                     .ThatSelfEvaluates()
                                     .ImplementStateValidationRule());

            #endregion
        }
Esempio n. 2
0
        private void SetRegularExpressions()
        {
            #region Age2 must be 1-99

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be 1-99", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2")),
                TargetPath = "age2"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
                Mask        = Mask.None
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .RegularExpression(ValidationMeta.ZeroToNinetyNineRange)
                             .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            #endregion
        }
Esempio n. 3
0
        private void SetValueCounts()
        {
            #region Injuries can only have one value when N or M is used

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "injuries");

            ValidationMessage = new ValidationMessage(string.Format("{0} can only have one value when N or M is used", TargetFieldLabel), "injuries");

            TargetField = new ValidationField
            {
                FieldPath   = "injuries",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).ValueCount("1")
                             .WithConditions()
                             .Contains(TargetField, new List <string> {
                "N", "M"
            })
                             .ThatSelfEvaluates()
                             .SetRuleImplementation(RuleImplementation)
                             .ImplementStateValidationRule();

            ValidationRule.ValidationId = string.Format("{0} can only have one value when N is selected", TargetFieldLabel); // Nibrs override
            NibrsValidationRules.Add(ValidationRule);

            #endregion
        }
Esempio n. 4
0
        private void SetRegularExpressions()
        {
            #region Latitude must be in the format 99.99999 with at least 5 decimal places (Event)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be in the format 99.99999 with at least 5 decimal places", TargetFieldLabel),
                TargetPath = "address.latitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .RegularExpression(ValidationMeta.Latitude5Places)
                                     .ImplementStateValidationRule());

            #endregion

            #region Longitude must be in the format -99.99999 with at least 5 decimal places (Event)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be in the format -99.99999 with at least 5 decimal places", TargetFieldLabel),
                TargetPath = "address.longitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .RegularExpression(ValidationMeta.Longitude5Places)
                                     .ImplementStateValidationRule());

            #endregion
        }
Esempio n. 5
0
        private void SetRange()
        {
            #region Latitude must be in the range 34.85654 to 36.75412

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be in the range 34.85654 to 36.75412", TargetFieldLabel),
                TargetPath = "address.latitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .Range("34.85654", "36.75412")
                                     .ImplementStateValidationRule());

            #endregion

            #region Longitude must be in the range -81.59809 to -90.49735

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0}  must be in the range -81.59809 to -90.49735", TargetFieldLabel),
                TargetPath = "address.longitude"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, TargetField)
                                     .Range("-81.59809", "-90.49735")
                                     .ImplementStateValidationRule());

            #endregion
        }
Esempio n. 6
0
        private void SetCustoms()
        {
            #region At least 2 Group A Offenses are required when AggravatedAssaults has a value of 08 (excludes UCR codes 978, 979, 992, and 980)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "aggravatedAssaults");

            var groupA = ValidationMeta.NibrsGroupAOffenses;
            groupA.Remove("978");
            groupA.Remove("979");
            groupA.Remove("992");
            groupA.Remove("980");

            ValidationMessage = new ValidationMessage(string.Format("At least 2 Group A Offenses are required when {0} has a value of 08 (excludes UCR codes 978, 979, 992, and 980)", TargetFieldLabel), "aggravatedAssaults");

            TargetField = new ValidationField
            {
                FieldPath   = "aggravatedAssaults",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).CustomValidation(
                    "aggravatedAssaults2GroupAOffenses")
                .Contains(new List <string> {
                "08"
            })
                .WithConditions()
                .Contains(ValidationField.ViolationCodeOffenses(), groupA)
                .ThatSelfEvaluates()
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            ValidationRule.Operation.Operand       = "aggravatedAssaults2GroupAOffenses";
            ValidationRule.Operation.OperationType = ValidationOperationType.Custom;

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    ValidationField.ViolationCodeOffenses()).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            #endregion
        }
Esempio n. 7
0
        private void CompareToCurrentDate()
        {
            #region StartDate must be on or before the current date

            NibrsValidationRules.Add(new Validation(
                                         new ValidationMessage
            {
                Message    = string.Format("{0} must be on or before the current date", ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "startDate")),
                TargetPath = "startDate"
            },
                                         new ValidationField
            {
                FieldPath     = "startDate",
                SectionName   = GenericSectionName.EVENT,
                ControlType   = ControlType.Date,
                Mask          = Mask.DateTime,
                CompareToMask = Mask.Date
            }).CompareToCurrentDate().ImplementStateValidationRule());

            #endregion
        }
Esempio n. 8
0
        private void SetRequired()
        {
            #region StartDate is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "startDate")),
                TargetPath = "startDate"
            },
                    new ValidationField
            {
                FieldPath   = "startDate",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Date
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Arrest Type is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "arrestType")),
                TargetPath = "arrestType"
            },
                    new ValidationField
            {
                FieldPath   = "arrestType",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Multiple Arrest Segments is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "multipleArrestSegments")),
                TargetPath = "multipleArrestSegments"
            },
                    new ValidationField
            {
                FieldPath   = "multipleArrestSegments",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Arrestee Armed With is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "arresteeArmedWith")),
                TargetPath = "arresteeArmedWith"
            },
                    new ValidationField
            {
                FieldPath   = "arresteeArmedWith",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Multiselect
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Race is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "race")),
                TargetPath = "race"
            },
                    new ValidationField
            {
                FieldPath   = "race",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Sex is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "sex")),
                TargetPath = "sex"
            },
                    new ValidationField
            {
                FieldPath   = "sex",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Age is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age")),
                TargetPath = "age"
            },
                    new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Ethnicity is required

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "ethnicity")),
                TargetPath = "ethnicity"
            },
                    new ValidationField
            {
                FieldPath   = "ethnicity",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region ViolationCode is required (Charge)

            NibrsValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message    = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "violationCodeReference")),
                TargetPath = "violationCodeReference"
            },
                    new ValidationField
            {
                FieldPath   = "violationCodeReference",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Offense
            })
                .Required().ImplementStateValidationRule());

            #endregion
        }
Esempio n. 9
0
        private void SetCustoms()
        {
            #region Disposition is required when Age is less than 18 or the average of the age range is less than 18

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "dispositionUnder18");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required when {1} is less than 18 or the average of the age range is less than 18", TargetFieldLabel, AssociatedField1Label), "dispositionUnder18");

            TargetField = new ValidationField
            {
                FieldPath   = "dispositionUnder18",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath   = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).CustomValidation(
                    "dispositionRequiredWhenAgeOrAverageLessThan18")
                .ThatSelfEvaluates()
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField1).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField2).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            #endregion

            #region Disposition can only be entered when Age is less than 18 or the average of the age range is less than 18

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "dispositionUnder18");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage(string.Format("{0} can only be entered when {1} is less than 18 or the average of the age range is less than 18", TargetFieldLabel, AssociatedField1Label), "dispositionUnder18");

            TargetField = new ValidationField
            {
                FieldPath   = "dispositionUnder18",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath   = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).CustomValidation(
                    "dispositionNotRequiredWhenAgeOrAverageMoreThan18")
                .ThatSelfEvaluates()
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField1).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField2).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            #endregion
        }
Esempio n. 10
0
        private void SetContains()
        {
            #region Sex must be M or F

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "sex");

            NibrsValidationRules.Add(new Validation(
                                         new ValidationMessage
            {
                Message    = string.Format("{0} must be M or F", TargetFieldLabel),
                TargetPath = "sex"
            },
                                         new ValidationField
            {
                FieldPath   = "sex",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            }).Contains(new List <string> {
                "M", "F"
            }).ImplementStateValidationRule());

            #endregion

            #region Age must be 01-17 when Offense has a UCR Code of 90I

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be 01-17 when Offense has a UCR Code of 90I", TargetFieldLabel),
                TargetPath = "age"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Contains(new List <string> {
                "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17"
            })
                .WithConditions()
                .SectionRequired(ValidationField.ViolationCodeArrestCharges(), new List <string> {
                "90I"
            })
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    ValidationField.ViolationCodeArrestCharges()).ThatBroadcasts()
                                     .SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            #endregion

            #region ViolationCode can NOT have a UCR code of 09C

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES,
                                                 "violationCodeReference");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} can NOT have a UCR code of 09C", TargetFieldLabel),
                TargetPath = "violationCodeReference",
            };

            NibrsValidationRules.Add(new Validation(ValidationMessage, ValidationField.ViolationCodeArrestCharges())
                                     .DoesNotContain(new List <string> {
                "09C"
            })
                                     .SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());

            #endregion

            #region Age2 must be blank when Age is 00, 1-6 Days, 7-364 Days Old, Under 24 Hours, NN, BB, NB0 (Suspects, Victims)

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be blank when {1} is 00, NB, 99, NN, BB or blank", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "age2",
            };

            TargetField = new ValidationField
            {
                FieldPath   = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).NotRequired()
                .WithOrConditions()
                .Contains(AssociatedField1, new List <string> {
                "00", "99", "NN", "BB", "NB"
            })
                .NotRequired(AssociatedField1)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion

            #region ViolationCode must have a UCR code of 64A when Offender age is <= 18 and UCR was 40A or 40B -Human Trafficking change

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage
            {
                Message = string.Format("{0} cannot be between 00-18 when an Arrest Charge has a UCR Code of Prostitution (40A) "
                                        + "or Assisting/Promoting Prostitution (40B). UCR Code must be Human Trafficking - Commercial "
                                        + "Sex Acts (64A)", TargetFieldLabel),
                TargetPath = "age"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            };

            var agerange = new List <string>();
            for (var i = 0; i < 19; i++)
            {
                agerange.Add(i.ToString("00"));
            }

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .DoesNotContain(agerange)
                .WithConditions()
                .SectionRequired(ValidationField.ViolationCodeArrestCharges(), new List <string> {
                "40A", "40B"
            })
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    ValidationField.ViolationCodeArrestCharges()).ThatBroadcasts()
                                     .ImplementStateValidationRule());

            #endregion
        }
Esempio n. 11
0
        public void SetComparisons()
        {
            #region Age2 must be greater than Age

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be greater than {1}", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "age2"
            };

            TargetField = new ValidationField
            {
                FieldPath     = "age2",           //age
                SectionName   = GenericSectionName.ARRESTEE,
                ControlType   = ControlType.Text, //Text
                Mask          = Mask.None,
                CompareToMask = Mask.None
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath     = "age", //age2
                SectionName   = GenericSectionName.ARRESTEE,
                ControlType   = ControlType.Code,
                Mask          = Mask.None,
                CompareToMask = Mask.None
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Comparison(ValidationOperand.GreaterThan).ImplementStateValidationRule();
            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion

            #region Age2 must be blank when Age is NOT an exact age

            /*
             * TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");
             * AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");
             *
             * ValidationMessage = new ValidationMessage(string.Format("{0} must be blank when {1} is NOT an exact age", TargetFieldLabel, AssociatedField1Label), "age2");
             *
             * TargetField = new ValidationField
             * {
             *  FieldPath = "age2",
             *  SectionName = GenericSectionName.ARRESTEE,
             *  ControlType = ControlType.Text,
             * };
             *
             * AssociatedField1 = new ValidationField
             * {
             *  FieldPath = "dateOfBirth",
             *  SectionName = GenericSectionName.ARRESTEE,
             *  ControlType = ControlType.Date,
             *  Mask = Mask.Date,
             * };
             *
             * ValidationRule =
             *  new Validation(ValidationMessage, TargetField).NotRequired()
             *      .WithConditions()
             *      .NotRequired(AssociatedField1)
             *      .ImplementStateValidationRule();
             *
             * NibrsValidationRules.Add(ValidationRule);
             * NibrsValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
             */
            #endregion
        }
Esempio n. 12
0
        private void SetRequired()
        {
            #region MethodOfEntry required when Offense has a UCR code of 220, 23F, 23G, or 240

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "methodOfEntry");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES,
                                                      "violationCodeReference");

            ValidationMessage = new ValidationMessage(string.Format("{0} required when Offense has a UCR code of 220, 23F, 23G, or 240", TargetFieldLabel), "methodOfEntry");

            TargetField = new ValidationField
            {
                FieldPath   = "methodOfEntry",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .Required()
                             .WithConditions()
                             .Contains(ValidationField.ViolationCodeOffenses(), new List <string> {
                "220", "23F", "23G", "240"
            })
                             .SetRuleImplementation(RuleImplementation)
                             .ImplementStateValidationRule();

            ValidationRule.ValidationId = string.Format("{0} is required when {1} has a UCR Code of 220", TargetFieldLabel, AssociatedField1Label);

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            #endregion

            #region MethodOfEntry can only be entered if Offense is 220, 23F, 23G, or 240

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "methodOfEntry");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES,
                                                      "violationCodeReference");

            ValidationMessage = new ValidationMessage(String.Format("{0} can only be entered if Offense is 220, 23F, 23G, or 240", TargetFieldLabel), "methodOfEntry");

            TargetField = new ValidationField
            {
                FieldPath   = "methodOfEntry",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(ValidationField.ViolationCodeOffenses(), new List <string> {
                "220", "23F", "23G", "240"
            })
                  .SetRuleImplementation(RuleImplementation)
                  .ImplementStateValidationRule();

            ValidationRule.ValidationId = string.Format("{0} must be blank when {1} does NOT have a UCR Code of 220", TargetFieldLabel, AssociatedField1Label);

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            #endregion

            #region SecondLocationType required when LocationType is 18

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "secondLocationType");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "offenseLocationType");

            ValidationMessage = new ValidationMessage(string.Format("{0} required when {1} is 18", TargetFieldLabel, AssociatedField1Label), "secondLocationType");

            TargetField = new ValidationField
            {
                FieldPath   = "secondLocationType",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "offenseLocationType",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).Required()
                .WithConditions()
                .Contains(AssociatedField1, new List <string> {
                "18"
            })
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion
        }
Esempio n. 13
0
        private void SetRequired()
        {
            #region DrugActivity is required when ViolationCode has a UCR Code of 35A

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "primaryDrugActivity");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "violationCodeReference");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} is required when {1} has a UCR of 35A", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "primaryDrugActivity"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "primaryDrugActivity",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .WithConditions()
                .SectionRequired(ValidationField.ViolationCodeArrestCharges(), new List <string> {
                "35A"
            })
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    ValidationField.ViolationCodeArrestCharges()).ThatBroadcasts()
                                     .SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());


            #endregion

            #region DrugType is required when ViolationCode has a UCR Code of 35A

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "primaryDrugType");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "violationCodeReference");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} is required when {1} has a UCR of 35A", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "primaryDrugType"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "primaryDrugType",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .WithConditions()
                .SectionRequired(ValidationField.ViolationCodeArrestCharges(), new List <string> {
                "35A"
            })
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);

            NibrsValidationRules.Add(new Validation(ValidationMessage,
                                                    ValidationField.ViolationCodeArrestCharges()).ThatBroadcasts()
                                     .SetRuleImplementation(RuleImplementation)
                                     .ImplementStateValidationRule());
            #endregion
        }
Esempio n. 14
0
        private void SetRequired()
        {
            #region Address is required when Latitude or Longitude is blank

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.streetAddress");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} is required when {1} or {2} is blank", TargetFieldLabel, AssociatedField1Label, AssociatedField2Label),
                TargetPath = "address.streetAddress"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.streetAddress",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Required()
                             .WithOrConditions()
                             .NotRequired(AssociatedField1)
                             .NotRequired(AssociatedField2)
                             .ThatBroadcasts()
                             .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField2).ThatBroadcasts().ImplementStateValidationRule());

            #endregion

            #region City is required when Latitude or Longitude is blank

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.city");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} is required when {1} or {2} is blank", TargetFieldLabel, AssociatedField1Label, AssociatedField2Label),
                TargetPath = "address.city"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.city",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Required()
                             .WithOrConditions()
                             .NotRequired(AssociatedField1)
                             .NotRequired(AssociatedField2).ThatBroadcasts()
                             .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField2).ThatBroadcasts().ImplementStateValidationRule());

            #endregion

            #region State is required when Latitude or Longitude is blank

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.state");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} is required when {1} or {2} is blank", TargetFieldLabel, AssociatedField1Label, AssociatedField2Label),
                TargetPath = "address.state"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.state",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Required()
                             .WithOrConditions()
                             .NotRequired(AssociatedField1)
                             .NotRequired(AssociatedField2).ThatBroadcasts()
                             .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField2).ThatBroadcasts().ImplementStateValidationRule());

            #endregion

            #region Zip is required when Latitude or Longitude is blank

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.zipCode");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.latitude");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "address.longitude");

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} is required when {1} or {2} is blank", TargetFieldLabel, AssociatedField1Label, AssociatedField2Label),
                TargetPath = "address.zipCode"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "address.zipCode",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "address.latitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath   = "address.longitude",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Required()
                             .WithOrConditions()
                             .NotRequired(AssociatedField1)
                             .NotRequired(AssociatedField2).ThatBroadcasts()
                             .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            NibrsValidationRules.Add(new Validation(ValidationMessage, AssociatedField2).ThatBroadcasts().ImplementStateValidationRule());

            #endregion

            #region DuiCause is required when ViolationCode has a UCR of 90D

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "duiCause");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "violationCodeReference");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required when {1} has a UCR of 90D", TargetFieldLabel, AssociatedField1Label), "duiCause");

            TargetField = new ValidationField
            {
                FieldPath   = "duiCause",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "violationCodeReference",
                ControlType = ControlType.Offense,
                SectionName = GenericSectionName.ARREST_CHARGES,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).Required()
                .WithConditions()
                .Contains(AssociatedField1,
                          new List <string>
            {
                "90D",
            })
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            NibrsValidationRules.Add(ValidationRule);
            NibrsValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion
        }