Skip to content

Commit

Permalink
Add license plate validation for class init arg
Browse files Browse the repository at this point in the history
  • Loading branch information
j4asper committed Mar 18, 2023
1 parent 49eeb9c commit c4b26a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dmr/dmr_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ def __from_dict(self, data):
self._raw_data=data
self._insurance = Insurance(**data["insurance"])
return self
def validate_license_plate(self, license_plate:str) -> bool:

def validate_license_plate(self, license_plate:str = None) -> bool:
"""Checks if the given string can be a license plate, this check is prior to the webscraping.
Args:
license_plate (str): The license plate to check
Returns:
bool: Returns True if the string could be a license plate, or False if not.
bool: Returns True if the given license plate could be a license plate, or False if not.
"""
if license_plate is None:
license_plate = self.registration_number
return len(license_plate) <= 7 and len(license_plate) >= 2 and license_plate.isalnum()

def to_dict(self):
Expand Down

0 comments on commit c4b26a1

Please sign in to comment.