Repository: deepset-ai/haystack

Issue:
PreProcessor from json config `{'split_by': null}` gives schema validation problem
**Describe the bug**
We are using JSONs as configs for our pipelines. When loading the pipeline from JSON, at validation time the PreProcessor node gives a validation error when using `split_by: null`. Being able to use `split_by: null` or in python code `split_by=None` was added in this PR: #3389 

**Error message**
![image](https://user-images.githubusercontent.com/25923343/203973567-0729f959-7098-4dfa-9361-183d6994d892.png)

**Expected behavior**
It should be able to load from json config

**To Reproduce**
Python code to reproduce:

```python
from haystack.pipelines.config import (
    validate_config,
)

pipeline_config = {
    "components": [
        {
            "name": "DocumentStore",
            "type": "ElasticsearchDocumentStore",
            "params": {
                "index": "documents",
                "search_fields": ["content"],
                "host": "localhost",
                "port": 9200,
            },
        },
        {"name": "ESRetriever", "type": "BM25Retriever"},
        {
            "name": "Preprocessor",
            "type": "PreProcessor",
            "params": {"split_by": None},
        },
    ],
    "pipelines": [
        {"name": "query", "nodes": [{"name": "ESRetriever", "inputs": ["Query"]}]},
        {
            "name": "indexing",
            "nodes": [
                {"name": "Preprocessor", "inputs": ["File"]},
                {"name": "DocumentStore", "inputs": ["Preprocessor"]},
            ],
        },
    ],
    "version": "1.11.0",
}
validate_config(pipeline_config, False)
```

If you change `split_by` to "word" it works:

```python
from haystack.pipelines.config import (
    validate_config,
)

pipeline_config = {
    "components": [
        {
            "name": "DocumentStore",
            "type": "ElasticsearchDocumentStore",
            "params": {
                "index": "documents",
                "search_fields": ["content"],
                "host": "localhost",
                "port": 9200,
            },
        },
        {"name": "ESRetriever", "type": "BM25Retriever"},
        {
            "name": "Preprocessor",
            "type": "PreProcessor",
            "params": {"split_by": "word"},
        },
    ],
    "pipelines": [
        {"name": "query", "nodes": [{"name": "ESRetriever", "inputs": ["Query"]}]},
        {
            "name": "indexing",
            "nodes": [
                {"name": "Preprocessor", "inputs": ["File"]},
                {"name": "DocumentStore", "inputs": ["Preprocessor"]},
            ],
        },
    ],
    "version": "1.11.0",
}
validate_config(pipeline_config, False)
```



Discussion:
Hi @ugm2 ,

Thanks for raising this issue. There's already a new PreProcessor in PR state. Maybe you can look at it?

https://github.com/deepset-ai/haystack/pull/3557

Resolving patch:
diff --git a/haystack/nodes/preprocessor/preprocessor.py b/haystack/nodes/preprocessor/preprocessor.py
--- a/haystack/nodes/preprocessor/preprocessor.py
+++ b/haystack/nodes/preprocessor/preprocessor.py
@@ -55,7 +55,7 @@ def __init__(
         clean_header_footer: bool = False,
         clean_empty_lines: bool = True,
         remove_substrings: List[str] = [],
-        split_by: Literal["word", "sentence", "passage", None] = "word",
+        split_by: Optional[Literal["word", "sentence", "passage"]] = "word",
         split_length: int = 200,
         split_overlap: int = 0,
         split_respect_sentence_boundary: bool = True,
@@ -127,7 +127,7 @@ def process(
         clean_header_footer: Optional[bool] = None,
         clean_empty_lines: Optional[bool] = None,
         remove_substrings: List[str] = [],
-        split_by: Literal["word", "sentence", "passage", None] = None,
+        split_by: Optional[Literal["word", "sentence", "passage"]] = None,
         split_length: Optional[int] = None,
         split_overlap: Optional[int] = None,
         split_respect_sentence_boundary: Optional[bool] = None,
@@ -175,7 +175,7 @@ def _process_single(
         clean_header_footer: Optional[bool] = None,
         clean_empty_lines: Optional[bool] = None,
         remove_substrings: List[str] = [],
-        split_by: Literal["word", "sentence", "passage", None] = None,
+        split_by: Optional[Literal["word", "sentence", "passage"]] = None,
         split_length: Optional[int] = None,
         split_overlap: Optional[int] = None,
         split_respect_sentence_boundary: Optional[bool] = None,
@@ -281,7 +281,7 @@ def clean(
     def split(
         self,
         document: Union[dict, Document],
-        split_by: Literal["word", "sentence", "passage", None],
+        split_by: Optional[Literal["word", "sentence", "passage"]],
         split_length: int,
         split_overlap: int,
         split_respect_sentence_boundary: bool,


Test patch: