def METHOD_NAME(value):
    if not isinstance(value, list):
        raise ValidationError('ports must be a list')
    if len(value) != 1:
        raise ValidationError('ports must be a list with exactly one'
                              'element')
    port = value.pop()
    if isinstance(port, str):
        try:
            port = int(port)
        except ValueError as e:
            raise ValidationError('The value must be a number') from e
    if port > 65535 or port < 1:
        raise ValidationError('The value must be in the range [1-65535]')
    return str(port)