Skip to content

Commit

Permalink
strip whitespace from query target input, closes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Sep 28, 2020
1 parent fde39bf commit be7a364
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hyperglass/api/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
from datetime import datetime

# Third Party
from pydantic import BaseModel, StrictStr, validator
from pydantic import BaseModel, StrictStr, validator, constr

# Project
from hyperglass.log import log
from hyperglass.exceptions import InputInvalid
from hyperglass.configuration import params, devices
from hyperglass.api.models.types import SupportedQuery
Expand Down Expand Up @@ -55,7 +54,7 @@ class Query(BaseModel):
query_location: StrictStr
query_type: SupportedQuery
query_vrf: StrictStr
query_target: StrictStr
query_target: constr(strip_whitespace=True, min_length=1)

class Config:
"""Pydantic model configuration."""
Expand Down Expand Up @@ -229,8 +228,8 @@ def validate_query_vrf(cls, value, values):
def validate_query_target(cls, value, values):
"""Validate query target value based on query_type."""

log.debug(values)
query_type = values["query_type"]
value = value.strip()

# Use relevant function based on query_type.
validator_map = {
Expand Down

0 comments on commit be7a364

Please sign in to comment.