Bean IO supports several common field validation rules when reading an input stream.
All field validation rules are validated against the field text before type conversion.
A template is a reusable list of components (segments, fields, and properties/constants) that can be included by a record, segment or other template.
The following example illustrates some of the ways a template can be used: configurations bound to the bean.
For this reason, when unmarshalling untrusted sources, it is recommended that you read the stream twice, using the first pass to validate the integrity of the file including syntax, record identification, record ordering, possible header/trailer counts, etc.
For example, the following mapping file might be used to validate our orders file. This section provides further details for using Bean IO to marshall and unmarshall Java objects to and from XML formatted streams.
The first pass can use a SAX parser or other means to validate the XML, and the second pass can use Bean IO to parse and process bean objects read from the document.