@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Validate
ErrorManager
.
The first parameter for methods with this annotation should be one of the Syntax
types. The second parameter should be
of type ErrorManager
. This error manager should be used to report any problems during validation.
It is generally better to subscribe the the most specific unit as possible (e.g., UrlFunctionValue
instead of Declaration
), however note that specific syntax types will not be delivered if the parent type is not refined. See the main
readme file for more information about refinement. Generally, if you are parsing with AutoRefine
or StandardValidation
then all syntax types will be delivered.
Validation always occurs after Observe
and Rework
subscription methods. This is based on the
assumption that validation should happen last, and it prevents validating the same thing over and over as a result of rework or
other changes (and also ensures that new or changed units as a result of rework are validated as well).
Important: Do not perform any modifications in a Validate
method! The only thing the method should do is check
for certain conditions and report an error to the ErrorManager
if applicable. All rework must be done in a method
annotation with Rework
, which is mutually exclusive with this annotation.
If you have a situation where both rework and validation are required, split it into separate methods, one with Rework
and one with Validate
. Of course as mentioned, the assumption is that all validation should be done last, not before,
any rework is done. If this is not true, perhaps try rethinking about the relationship between the rework and validation and
refactor accordingly.
Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.