def validate_bias_position_arg()

in geocoding_lambda/lambda_function.py [0:0]


def validate_bias_position_arg(arg: str) -> Tuple[bool, Optional[List[float]]]:
  logger = logging.getLogger(__name__)
  bias_position_arg = None
  try:
    assert isinstance(arg, str) and len(arg.strip())
    bias_position_arg = json.loads(arg)
  except (AssertionError, JSONDecodeError) as exc:
    logger.debug(exc)
    logger.error('Argument provided is not a JSON string.')
    return False, None

  try:
    assert isinstance(bias_position_arg, list) and len(bias_position_arg) == 2
    for bias_coord in bias_position_arg:
      assert isinstance(bias_coord, float)
  except AssertionError as exc:
    logger.debug(exc)
    logger.error('Argument provided is not a list of float numbers.')
    return False, None

  return True, bias_position_arg