From 511591feb02396a403222f0d8a18dba33d573832 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sat, 10 Jun 2023 16:45:17 -0500 Subject: http-api: T5263: path validator should provide message --- src/services/vyos-http-api-server | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/services/vyos-http-api-server b/src/services/vyos-http-api-server index acaa383b4..89c685f32 100755 --- a/src/services/vyos-http-api-server +++ b/src/services/vyos-http-api-server @@ -96,9 +96,10 @@ class BaseConfigureModel(BaseModel): path: List[StrictStr] value: StrictStr = None - @validator("path", pre=True, always=True) + @validator("path") def check_non_empty(cls, path): - assert len(path) > 0 + if not len(path) > 0: + raise ValueError('path must be non-empty') return path class ConfigureModel(ApiModel): @@ -106,9 +107,10 @@ class ConfigureModel(ApiModel): path: List[StrictStr] value: StrictStr = None - @validator("path", pre=True, always=True) + @validator("path") def check_non_empty(cls, path): - assert len(path) > 0 + if not len(path) > 0: + raise ValueError('path must be non-empty') return path class Config: -- cgit v1.2.3