def params_valid(spec: str, params: list) -> bool:
    """
    check the params in valid according to the spec.
    required params syntax: <param>
    optional params syntax: [param]
    any params syntax(MUST BE LAST ONE): [params ...]
    """
    spec_arr = spec.split()
    real_params_len = len(params)
    required_len = len([x for x in spec_arr if x[0]=='<'])
    if real_params_len < required_len:
        return False
    if spec.endswith("...]"):
        return True
    optionals = [x for x in spec_arr if x[0]=='[']
    optional_len = len(optionals)
    if real_params_len > required_len + optional_len:
        return False
    return True