|
NameOpenXPKI::Server::Workflow::ValidatorSYNOPSISmy_validator class: OpenXPKI::Server::Workflow::Validator::MyValidatorClass param: _map_path: [% context.key_in_context %] arg: - $cert_profile - $cert_subject_style - "[% context.other_key_in_context %]" DescriptionA base clase for Validators, providing some magic for handling parameters and arguments.Parameter MappingAll parameters (instance configuration), can use the _map syntax to resolve values from the context. @see OpenXPKI::Server::Workflow::Activity. Note: Validators are created ONCE per workflow instance and the parameters are read and evaluated when the validator is created first.Argument ParsingThe Workflow base class already replaces arguments starting with a dollar sign by the approprate context values. In addition, argument values starting with a template toolkit sequence [%... are parsed using OpenXPKI::Template with the full workflow context as parameters and the given argument as template.Sub-ClassingvalidationTo implement your own validator you need use Moose and inherit from this class. Please implement your code in a method called _validate, starting with and underscore! If you dont need the features from this class, you can also subclass directly from Workflow::Validator.Validation errors MUST be thrown using the validation_error method. The first argument MUST be a verbose description starting with I18N_OPENXPKI_UI_, you SHOULD pass a list of the fields that caused the error as second argument: validation_error ('I18N_OPENXPKI_UI_VALIDATOR_FIELD_HAS_ERRORS', { invalid_fields => \@fields_with_error } ); Where each item in the list is a hash with the key name and, optional, additional infos on the error. (this is not fully specified and also not evaluated on the UI) presetThe validator pattern is usually not bound to the context sensitive and expects the values to be validated as arguments. As OpenXPKI widely uses normalized context key names, you can define a preset list to be used instead of arguments set in the config. Define the sub _preset_args:sub _preset_args { return [ qw(cert_profile cert_subject_style) ]; } If no arguments are set in the validator definition, the constructor reads the context values at the given keys and injects them as arguments to the _validate method. The given preset example will set the first two arguments in the same way as the initial example code with the third parameter remaining undefined. Note: The preset arguments are not expanded! You need to pass the context keys as string without leading "$" and can not use templates or static values. LoggingLog event for validation process must use facility application and should use priorities error and debug. Configuration errors should trigger OpenXPKI::Exception and log to workflow/error.
Visit the GSP FreeBSD Man Page Interface. |