Java對象驗證框架 - iScreen
iScreen是一個Java對象驗證框架。它的思想與Apache Jakarta的commons-validator項目相似,驗證規則使用XML進行配置但也支持其它配置類型。它比commons-validator更強大,靈活,易于使用。
Java Object Validation
Validation is done via Java objects. Typically, these will be JavaBeans, but this is not required. OGNL (see www.ognl.org) is used to access object fields, which gives considerable flexibility in what is eventually validated.
InternationalizationThough currently somewhat weak (meaning, it needs a lot more work before it's done), basic internationalization support exists via resource bundles.
Multiple FieldsFundamental support for pulling multiple fields from a Java object and validating them together is supported. The capability, unlike most validation frameworks, is not tacked on, but is supported as a natural configuration capability.
XML ConfigurationThough the underlying engine supports configuration by other means, the primary configuration format is XML. In the future, additional formats will become available.
Configuration ReuseThe feature is tied to the XML configuration capability. This re-use allows validations to be referenced by other validations via delegation. This is interesting because it simplifies and minimizes the configuration.
Dynamic Failure MessagesFailure messages that are generated during validation are dynamically generated. Not only that, but each "validator" is configured with the message it will use (so, it's never hard-coded). These "validators" can also use multiple messages for different reasons (for example, imagine a validator that checks string lengths: it can use a different message for an invalid minimum length from the one it uses for maximum length).
Failures and WarningsThere are two types of errors that a validator can report: a failure and a warning. A warning is a failure that can be ignored (depending upon how the application wants to handle it).
Configuration-BasedDefinitions of validations are done via configuration in order to minimize the required amount of code. In fact, the amount of code necessary is fairly minimal. It's recommended that an inversion of control container be used to further minimize the necessary code.
OGNL AccessOGNL (see www.ognl.org) is used for basic mapping and Java object access. This object navigation library is extremely powerful, providing considerable flexibility in what data is being validated and how messages are generated.