forked from platformio/platformio-core
		
	* CLI to manage organizations. Resolve #3532 * fix tests * fix test * add org owner test * fix org test * fix invalid username/orgname error text * refactor auth request in clients * fix * fix send auth request * fix regexp * remove duplicated code. minor fixes. * Remove space Co-authored-by: Ivan Kravets <me@ikravets.com>
This commit is contained in:
		@@ -29,13 +29,15 @@ def cli():
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def validate_username(value):
 | 
			
		||||
def validate_username(value, field="username"):
 | 
			
		||||
    value = str(value).strip()
 | 
			
		||||
    if not re.match(r"^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){3,38}$", value, flags=re.I):
 | 
			
		||||
    if not re.match(r"^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,37}$", value, flags=re.I):
 | 
			
		||||
        raise click.BadParameter(
 | 
			
		||||
            "Invalid username format. "
 | 
			
		||||
            "Username must contain at least 4 characters including single hyphens,"
 | 
			
		||||
            " and cannot begin or end with a hyphen"
 | 
			
		||||
            "Invalid %s format. "
 | 
			
		||||
            "%s may only contain alphanumeric characters "
 | 
			
		||||
            "or single hyphens, cannot begin or end with a hyphen, "
 | 
			
		||||
            "and must not be longer than 38 characters."
 | 
			
		||||
            % (field.lower(), field.capitalize())
 | 
			
		||||
        )
 | 
			
		||||
    return value
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user