File size: 528 Bytes
5da0109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
# SPDX-License-Identifier: Apache-2.0
#

from config import MAXIMUM_INPUT_LENGTH

def validate_text_input(text_content):
    if not text_content or not isinstance(text_content, str):
        return False, ""

    cleaned_text = text_content.strip()

    if not cleaned_text:
        return False, ""

    if len(cleaned_text) > MAXIMUM_INPUT_LENGTH:
        return False, f"Input exceeds maximum length of {MAXIMUM_INPUT_LENGTH} characters."

    return True, cleaned_text