當前位置: 首頁>>代碼示例>>Python>>正文


Python validators.MinLengthValidator方法代碼示例

本文整理匯總了Python中django.core.validators.MinLengthValidator方法的典型用法代碼示例。如果您正苦於以下問題:Python validators.MinLengthValidator方法的具體用法?Python validators.MinLengthValidator怎麽用?Python validators.MinLengthValidator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.core.validators的用法示例。


在下文中一共展示了validators.MinLengthValidator方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, *args, **kwargs):
        try:
            self.model_field = kwargs.pop('model_field')
        except KeyError:
            raise ValueError("ModelField requires 'model_field' kwarg")

        self.min_length = kwargs.pop('min_length',
                                     getattr(self.model_field, 'min_length', None))
        self.max_length = kwargs.pop('max_length',
                                     getattr(self.model_field, 'max_length', None))
        self.min_value = kwargs.pop('min_value',
                                    getattr(self.model_field, 'min_value', None))
        self.max_value = kwargs.pop('max_value',
                                    getattr(self.model_field, 'max_value', None))

        super(ModelField, self).__init__(*args, **kwargs)

        if self.min_length is not None:
            self.validators.append(validators.MinLengthValidator(self.min_length))
        if self.max_length is not None:
            self.validators.append(validators.MaxLengthValidator(self.max_length))
        if self.min_value is not None:
            self.validators.append(validators.MinValueValidator(self.min_value))
        if self.max_value is not None:
            self.validators.append(validators.MaxValueValidator(self.max_value)) 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:27,代碼來源:fields.py

示例2: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        self.max_length, self.min_length = max_length, min_length
        super(CharField, self).__init__(*args, **kwargs)
        if min_length is not None:
            self.validators.append(validators.MinLengthValidator(int(min_length)))
        if max_length is not None:
            self.validators.append(validators.MaxLengthValidator(int(max_length))) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:9,代碼來源:fields.py

示例3: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, *, max_length=None, min_length=None, strip=True, empty_value='', **kwargs):
        self.max_length = max_length
        self.min_length = min_length
        self.strip = strip
        self.empty_value = empty_value
        super().__init__(**kwargs)
        if min_length is not None:
            self.validators.append(validators.MinLengthValidator(int(min_length)))
        if max_length is not None:
            self.validators.append(validators.MaxLengthValidator(int(max_length)))
        self.validators.append(validators.ProhibitNullCharactersValidator()) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:13,代碼來源:fields.py

示例4: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs):
        self.max_length = max_length
        self.min_length = min_length
        self.strip = strip
        self.empty_value = empty_value
        super(CharField, self).__init__(*args, **kwargs)
        if min_length is not None:
            self.validators.append(validators.MinLengthValidator(int(min_length)))
        if max_length is not None:
            self.validators.append(validators.MaxLengthValidator(int(max_length))) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:12,代碼來源:fields.py

示例5: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        self.max_length, self.min_length = max_length, min_length
        super(CharField, self).__init__(*args, **kwargs)
        if min_length is not None:
            self.validators.append(validators.MinLengthValidator(min_length))
        if max_length is not None:
            self.validators.append(validators.MaxLengthValidator(max_length)) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:9,代碼來源:fields.py

示例6: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, max_length=None, min_length=None, strip=True, *args, **kwargs):
        self.max_length = max_length
        self.min_length = min_length
        self.strip = strip
        super(CharField, self).__init__(*args, **kwargs)
        if min_length is not None:
            self.validators.append(validators.MinLengthValidator(int(min_length)))
        if max_length is not None:
            self.validators.append(validators.MaxLengthValidator(int(max_length))) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:11,代碼來源:fields.py

示例7: __init__

# 需要導入模塊: from django.core import validators [as 別名]
# 或者: from django.core.validators import MinLengthValidator [as 別名]
def __init__(self, *args, **kwargs):
        self.organization = kwargs.pop('organization', None)
        super(PartClassForm, self).__init__(*args, **kwargs)
        self.fields['code'].required = False
        self.fields['name'].required = False
        self.fields['code'].validators.extend([MaxLengthValidator(self.organization.number_class_code_len), MinLengthValidator(self.organization.number_class_code_len)]) 
開發者ID:mpkasp,項目名稱:django-bom,代碼行數:8,代碼來源:forms.py


注:本文中的django.core.validators.MinLengthValidator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。