Class StandardScriptValidator

  • All Implemented Interfaces:
    ScriptValidator

    public class StandardScriptValidator
    extends Object
    implements ScriptValidator
    Validates scripts using the standard JSR 223 script engine framework. The validator will retrieve the appropriate javax.script.ScriptEngine and establish if it is an instance of javax.script.Compilable. The Compilable instance will then be used to compile the script and convert the compilation errors to ScriptErrors.
    Since:
    12.0.0
    • Constructor Detail

      • StandardScriptValidator

        @Inject
        public StandardScriptValidator​(StandardScriptEngineManager scriptEngineManager)
        Constructs the script validator using the given JSR 223 script engine manager instance.
        Parameters:
        scriptEngineManager - the script engine manager to use for creating script engines.
        Throws:
        NullPointerException - if scriptEngineManager is not specified.
    • Method Detail

      • validateScript

        public List<ScriptError> validateScript​(ScriptObject script)
        Validate the given script for the particular language rules and produces a list of ScriptError instances if any validation errors occurred.
        Specified by:
        validateScript in interface ScriptValidator
        Parameters:
        script - the script that needs to be validated.
        Returns:
        a list of validation errors if validation failed and an empty list if validation passed.