Generic validation layer for object properties
A validation layer that facilitates the automatic annotation of object properties by the object with a validation attribute (e.g., FieldValidation), thereby specifying a set of validation rules declaratively, and scenarios under which these validation rules should fire. During build time, the validation layer iterates through each module and associated module classes to automatically generate the validation code. This not only makes the code more readable, but also ensures that a project has consistent validation handling. The validation layer applies to the annotation and validation at the property-level and inter-property. Thus, property-level validation is employed to ensure the correctness of individual values, and inter-property validation can be employed to ensure the correctness in combinations of values.
1 . A computer-implemented system that facilitates data validation, comprising:
an attribute component for tagging a data object with a validation attribute based on a write operation for the data object; and
a build component for automatically generating validation code at build time based on the attribute.
2 . The system of claim 1 , wherein the build component processes the validation code for exceptions.
3 . The system of claim 2 , wherein the data object is stored in a data store after the exceptions are cleared.
4 . The system of claim 1 , wherein the build component calls an application program interface (API) to execute the validation code for exceptions.
5 . The system of claim 4 , wherein the API executes the validation code for inconsistencies between related properties of the data object.
6 . The system of claim 1 , wherein the data object includes properties related to at least one of a null, a maximum length, minimum length, or matching criteria.
7 . The system of claim 1 , wherein the attribute component selectively tags the data object from a plurality of data objects.
8 . The system of claim 1 , further comprising an interception component for intercepting the write operation associated with writing the data object to a data store.
9 . A computer-implemented method of validating data, comprising:
annotating an object property of an object with a validation attribute;
specifying a set of validation rules based on the annotated property; and
automatically generating validation code at build time based on the annotated property.
10 . The method of claim 9 , further comprising annotating the object property, specifying the set of validation rules, and generating the validation code in response to receiving the object for persistence.
11 . The method of claim 9 , further comprising automatically annotating the object property for validation of a null.
12 . The method of claim 9 , further comprising automatically annotating the object property for validation of a maximum string length.
13 . The method of claim 9 , further comprising automatically annotating the object property for validation of a minimum string length.
14 . The method of claim 9 , further comprising generating the validation code during a build process for classes that have an annotated property.
15 . The method of claim 9 , further comprising calling an API for executing a business rule prior to persisting the object.
16 . The method of claim 9 , further comprising calling an API for generating an exception based on a validation failure.
17 . The method of claim 9 , further comprising automatically creating the object based on data entry into a property field.
18 . The method of claim 9 , further comprising:
intercepting a save operation;
processing the object through filtering rules; and
generating an exception based on failed validation of the object property.
19 . The method of claim 9 , further comprising checking consistency between two or more object properties as part of a validation process.
20 . A computer-implemented system, comprising:
computer-implemented means for annotating an object of an application module with a validation attribute;
computer-implemented means for specifying a set of validation rules based on the annotated object; and
computer-implemented means for automatically generating validation code at build time based on the annotated object.