code: def test_span_ruler_validate():
      nlp = spacy.blank("xx")
      ruler = nlp.add_pipe("span_ruler")
      validated_ruler = nlp.add_pipe(
          "span_ruler",
          name="validated_span_ruler",
          config={"validate": True},
      )
  
      valid_pattern = {
          "label": "HELLO",
          "pattern": [{"LOWER": "HELLO"}],
      }
      invalid_pattern = {
          "label": "HELLO",
          "pattern": [{"ASDF": "HELLO"}],
      }
  
      # invalid pattern raises error without validate
      with pytest.raises(ValueError):
          ruler.add_patterns([invalid_pattern])
  
      # valid pattern is added without errors with validate
      validated_ruler.add_patterns([valid_pattern])
  
      # invalid pattern raises error with validate
      with pytest.raises(MatchPatternError):
          validated_ruler.add_patterns([invalid_pattern])
  
imports: import pytest
  from thinc.api import NumpyOps, get_current_ops
  import spacy
  from spacy import registry
  from spacy.errors import MatchPatternError
  from spacy.tests.util import make_tempdir
  from spacy.tokens import Span
  from spacy.training import Example
label_desc: Use image node_id 14 for calling a global function with example usage: test_span_ruler_validate() without return types