chore: better name checks for ProgramElement
This commit is contained in:
@@ -7,7 +7,7 @@ University within the Software Project course.
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
|
|
||||||
from pydantic import UUID4, BaseModel
|
from pydantic import UUID4, BaseModel, field_validator
|
||||||
|
|
||||||
|
|
||||||
class ProgramElement(BaseModel):
|
class ProgramElement(BaseModel):
|
||||||
@@ -24,6 +24,13 @@ class ProgramElement(BaseModel):
|
|||||||
# To make program elements hashable
|
# To make program elements hashable
|
||||||
model_config = {"frozen": True}
|
model_config = {"frozen": True}
|
||||||
|
|
||||||
|
@field_validator("name")
|
||||||
|
@classmethod
|
||||||
|
def name_must_not_start_with_number(cls, v: str) -> str:
|
||||||
|
if v and v[0].isdigit():
|
||||||
|
raise ValueError('Field "name" must not start with a number.')
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
class LogicalOperator(Enum):
|
class LogicalOperator(Enum):
|
||||||
"""
|
"""
|
||||||
@@ -105,6 +112,7 @@ class InferredBelief(ProgramElement):
|
|||||||
left: Belief
|
left: Belief
|
||||||
right: Belief
|
right: Belief
|
||||||
|
|
||||||
|
|
||||||
class EmotionBelief(ProgramElement):
|
class EmotionBelief(ProgramElement):
|
||||||
"""
|
"""
|
||||||
Represents a belief that is set when a certain emotion is detected.
|
Represents a belief that is set when a certain emotion is detected.
|
||||||
@@ -115,6 +123,7 @@ class EmotionBelief(ProgramElement):
|
|||||||
name: str = ""
|
name: str = ""
|
||||||
emotion: str
|
emotion: str
|
||||||
|
|
||||||
|
|
||||||
class Norm(ProgramElement):
|
class Norm(ProgramElement):
|
||||||
"""
|
"""
|
||||||
Base class for behavioral norms that guide the robot's interactions.
|
Base class for behavioral norms that guide the robot's interactions.
|
||||||
|
|||||||
Reference in New Issue
Block a user