diff options
author | John Estabrook <jestabro@vyos.io> | 2023-06-10 16:45:17 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-06-10 22:39:28 -0500 |
commit | 511591feb02396a403222f0d8a18dba33d573832 (patch) | |
tree | 0e6b48e2bee5cce4cce47bcaa5af6ddb92e2f599 | |
parent | b01a7a06ae63c2f0bbeb60a8cef567f4d333be30 (diff) | |
download | vyos-1x-511591feb02396a403222f0d8a18dba33d573832.tar.gz vyos-1x-511591feb02396a403222f0d8a18dba33d573832.zip |
http-api: T5263: path validator should provide message
-rwxr-xr-x | src/services/vyos-http-api-server | 10 |
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: |