Skip to content

Commit

Permalink
pref: add PublisherDispatchConfig params validate
Browse files Browse the repository at this point in the history
  • Loading branch information
Undertone0809 committed Jun 16, 2023
1 parent c760406 commit efb24d1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions broadcast_service/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,21 @@ def start_publisher_callback_or_not(self) -> bool:
return False

@validator("num_of_executions")
def must_be_positive_integer(cls, v):
def check_num_of_executions(cls, v):
if v <= 0 or type(v) != int:
raise ValueError('num_of_execution must be a positive integer')
raise ValueError("num_of_execution must be a positive integer")
return v

@validator("interval")
def check_interval(cls, v):
if v < 0 or type(v) not in [int, float]:
raise ValueError("interval must be a positive float")
return v

@validator("split_parameters")
def check_split_parameters(cls, v):
if v and len(v) < cls.num_of_executions:
raise ValueError("The length of split_parameters must be the same as num_of_executions")
return v

def get_num_of_executions(self) -> int:
Expand Down

0 comments on commit efb24d1

Please sign in to comment.