summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-06-10 16:45:17 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-06-10 22:39:28 -0500
commit511591feb02396a403222f0d8a18dba33d573832 (patch)
tree0e6b48e2bee5cce4cce47bcaa5af6ddb92e2f599 /src
parentb01a7a06ae63c2f0bbeb60a8cef567f4d333be30 (diff)
downloadvyos-1x-511591feb02396a403222f0d8a18dba33d573832.tar.gz
vyos-1x-511591feb02396a403222f0d8a18dba33d573832.zip
http-api: T5263: path validator should provide message
Diffstat (limited to 'src')
-rwxr-xr-xsrc/services/vyos-http-api-server10
1 files changed, 6 insertions, 4 deletions
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: