예제 #1
0
파일: models.py 프로젝트: rizend/nb_donate
 def __declare_last__(cls):
     ValidateInteger(Transaction.ccy_id, False, True)
     ValidateNumeric(Transaction.amount, False, True)
     ValidateInteger(Transaction.payer_id, False, True)
     ValidateInteger(Transaction.recvr_id, False, True)
     ValidateInteger(Transaction.requestor_id, False, True)
     ValidateInteger(Transaction.approver_id, False, True)
예제 #2
0
    def define_validators(self):
        """
        Define Validators

        """
        ValidateInteger(self.DummyModel.integer)
        ValidateLessThan(self.DummyModel.integer, 100000)
        ValidateLessThanOrEqual(self.DummyModel.integer, 99999)
        ValidateInteger(self.DummyModel.int_exception, True, True)
        ValidateString(self.DummyModel.str_exception, True, True,
                       "Test Message")
        ValidateNumeric(self.DummyModel.numeric)
        ValidateString(self.DummyModel.string)
        ValidateBoolean(self.DummyModel.boolean)
        ValidateLength(self.DummyModel.string, 10, 2)
        ValidateEmail(self.DummyModel.email)
        ValidateRegex(self.DummyModel.regex, "[A-Z][a-z]+")
        ValidateIP(self.DummyModel.ip)
        ValidateIP(self.DummyModel.ipv6, True)
        ValidateURL(self.DummyModel.url)
        ValidateUUID(self.DummyModel.uuid)
        ValidateCountry(self.DummyModel.country)
        ValidateTimezone(self.DummyModel.timezone)
        ValidateLocale(self.DummyModel.locale)
        ValidateGreaterThan(self.DummyModel.large, 100)
        ValidateGreaterThanOrEqual(self.DummyModel.large, 101)
        ValidateCreditCard(self.DummyModel.creditcard)
        ValidateCurrency(self.DummyModel.currency)
        ValidateIBAN(self.DummyModel.iban)
        ValidateISBN(self.DummyModel.isbn)
        ValidateString(self.DummyModel.null, True)
        self.rangevalues = [11, 12, 13]
        ValidateRange(self.DummyModel.rangefield, self.rangevalues)
예제 #3
0
    def __declare_last__(cls):
        for col in cls.__table__.columns:
            type = col.type.python_type

            if type == str:
                ValidateString(getattr(cls, col.name),
                               allow_null=col.nullable,
                               throw_exception=True)
                if col.type.length:
                    ValidateLength(getattr(cls, col.name),
                                   col.type.length,
                                   throw_exception=True,
                                   message=f'Max length is { col.type.length}')
            elif type == int:
                ValidateInteger(getattr(cls, col.name),
                                allow_null=col.nullable,
                                throw_exception=True)
            elif type == float:
                ValidateNumeric(getattr(cls, col.name),
                                allow_null=col.nullable,
                                throw_exception=True)
            elif type == date:
                ValidateDate(getattr(cls, col.name),
                             allow_null=col.nullable,
                             throw_exception=True)
            elif type == datetime:
                ValidateDateTime(getattr(cls, col.name),
                                 allow_null=col.nullable,
                                 throw_exception=True)

        BaseModel.validators()
예제 #4
0
 def __declare_last__(cls):
     ValidateString(Account.name, False, True)
     ValidateInteger(Account.ccy_id, False, True)
예제 #5
0
 def __declare_last__(cls):
     ValidateNumeric(StripePlan.amount, False, True)
     ValidateString(StripePlan.name, False, True)
     ValidateInteger(StripePlan.ccy_id, False, True)
     ValidateString(StripePlan.interval, False, True)
 def __declare_last__(cls):
     ValidateInteger(User.integer)
     ValidateString(User.string, False, True, "Custom Message, "
                                              "Field {field} - Value {value} - Oldvalue {oldvalue} - Key {key}")
예제 #7
0
파일: models.py 프로젝트: rizend/nb_donate
 def __declare_last__(cls):
     ValidateString(Project.name, False, True)
     ValidateInteger(Project.account_id, False, True)
     ValidateNumeric(Project.goal, False, True)
예제 #8
0
파일: models.py 프로젝트: Yanruii/kaos
 def __declare_last__(cls):
     ValidateInteger(ResponseHistory.uid)
     ValidateString(ResponseHistory.response)
예제 #9
0
파일: models.py 프로젝트: Yanruii/kaos
 def __declare_last__(cls):
     ValidateInteger(Satellite.platform_id)
     ValidateString(Satellite.platform_name)
예제 #10
0
파일: models.py 프로젝트: Yanruii/kaos
 def __declare_last__(cls):
     ValidateInteger(OrbitRecord.uid)
예제 #11
0
파일: models.py 프로젝트: Yanruii/kaos
 def __declare_last__(cls):
     ValidateInteger(OrbitSegment.segment_id)
     ValidateInteger(OrbitSegment.platform_id)