code: def create_validator(
      function: Callable[[Text], bool], error_message: Text
  ) -> Type["Validator"]:
      """Helper method to create `Validator` classes from callable functions. Should be
      removed when questionary supports `Validator` objects.
      """
      from prompt_toolkit.validation import Validator, ValidationError
      from prompt_toolkit.document import Document
  
      class FunctionValidator(Validator):
          @staticmethod
          def validate(document: Document) -> None:
              is_valid = function(document.text)
              if not is_valid:
                  raise ValidationError(message=error_message)
  
      return FunctionValidator
  
imports: import asyncio
  import filecmp
  import logging
  import os
  import pickle
  import tempfile
  import warnings
  import re
  from asyncio import AbstractEventLoop
  from pathlib import Path
  from typing import Text, Any, Union, List, Type, Callable, TYPE_CHECKING, Pattern
  from typing_extensions import Protocol
  import rasa.shared.constants
  import rasa.shared.utils.io
label_desc: Use image node_id 10 for calling a global function with example usage: create_validator(function, error_message) and returns: FunctionValidator