new line check

This commit is contained in:
Bhavin Patel
2023-06-22 16:26:43 -07:00
parent a3625c5718
commit bcee80029d
@@ -6,6 +6,7 @@ from pydantic import BaseModel, validator, root_validator
from dataclasses import dataclass
from datetime import datetime
from typing import Union
import re
from bin.contentctl_project.contentctl_core.domain.entities.security_content_object import (
@@ -139,6 +140,15 @@ class Detection(BaseModel, SecurityContentObject):
raise ValueError("name is longer then 67 chars: " + values["name"])
return values
@root_validator
def description_new_line_check(cls, values):
# Check if there is a new line in description that is not escaped
pattern = r'(?<!\\)\n'
if re.search(pattern, values["description"]):
raise ValueError("desciption key contains new line but it is not escaped using backslash. Add backslash before a new line : " + values["name"])
return values
# @validator('references')
# def references_check(cls, v, values):
# return LinkValidator.SecurityContentObject_validate_references(v, values)