1616
1717import json
1818import re
19-
20- import six
21- from six .moves import urllib
19+ from urllib import parse
2220
2321from firebase_admin import exceptions
2422from firebase_admin import _utils
3533def validate_uid (uid , required = False ):
3634 if uid is None and not required :
3735 return None
38- if not isinstance (uid , six . string_types ) or not uid or len (uid ) > 128 :
36+ if not isinstance (uid , str ) or not uid or len (uid ) > 128 :
3937 raise ValueError (
4038 'Invalid uid: "{0}". The uid must be a non-empty string with no more than 128 '
4139 'characters.' .format (uid ))
@@ -44,7 +42,7 @@ def validate_uid(uid, required=False):
4442def validate_email (email , required = False ):
4543 if email is None and not required :
4644 return None
47- if not isinstance (email , six . string_types ) or not email :
45+ if not isinstance (email , str ) or not email :
4846 raise ValueError (
4947 'Invalid email: "{0}". Email must be a non-empty string.' .format (email ))
5048 parts = email .split ('@' )
@@ -61,7 +59,7 @@ def validate_phone(phone, required=False):
6159 """
6260 if phone is None and not required :
6361 return None
64- if not isinstance (phone , six . string_types ) or not phone :
62+ if not isinstance (phone , str ) or not phone :
6563 raise ValueError ('Invalid phone number: "{0}". Phone number must be a non-empty '
6664 'string.' .format (phone ))
6765 if not phone .startswith ('+' ) or not re .search ('[a-zA-Z0-9]' , phone ):
@@ -72,22 +70,22 @@ def validate_phone(phone, required=False):
7270def validate_password (password , required = False ):
7371 if password is None and not required :
7472 return None
75- if not isinstance (password , six . string_types ) or len (password ) < 6 :
73+ if not isinstance (password , str ) or len (password ) < 6 :
7674 raise ValueError (
7775 'Invalid password string. Password must be a string at least 6 characters long.' )
7876 return password
7977
8078def validate_bytes (value , label , required = False ):
8179 if value is None and not required :
8280 return None
83- if not isinstance (value , six . binary_type ) or not value :
81+ if not isinstance (value , bytes ) or not value :
8482 raise ValueError ('{0} must be a non-empty byte sequence.' .format (label ))
8583 return value
8684
8785def validate_display_name (display_name , required = False ):
8886 if display_name is None and not required :
8987 return None
90- if not isinstance (display_name , six . string_types ) or not display_name :
88+ if not isinstance (display_name , str ) or not display_name :
9189 raise ValueError (
9290 'Invalid display name: "{0}". Display name must be a non-empty '
9391 'string.' .format (display_name ))
@@ -96,7 +94,7 @@ def validate_display_name(display_name, required=False):
9694def validate_provider_id (provider_id , required = True ):
9795 if provider_id is None and not required :
9896 return None
99- if not isinstance (provider_id , six . string_types ) or not provider_id :
97+ if not isinstance (provider_id , str ) or not provider_id :
10098 raise ValueError (
10199 'Invalid provider ID: "{0}". Provider ID must be a non-empty '
102100 'string.' .format (provider_id ))
@@ -106,12 +104,12 @@ def validate_photo_url(photo_url, required=False):
106104 """Parses and validates the given URL string."""
107105 if photo_url is None and not required :
108106 return None
109- if not isinstance (photo_url , six . string_types ) or not photo_url :
107+ if not isinstance (photo_url , str ) or not photo_url :
110108 raise ValueError (
111109 'Invalid photo URL: "{0}". Photo URL must be a non-empty '
112110 'string.' .format (photo_url ))
113111 try :
114- parsed = urllib . parse .urlparse (photo_url )
112+ parsed = parse .urlparse (photo_url )
115113 if not parsed .netloc :
116114 raise ValueError ('Malformed photo URL: "{0}".' .format (photo_url ))
117115 return photo_url
0 commit comments