Esempio n. 1
0
    def getValidator(self, request):
        validators = {}
        pre_validators = []
        chained_validators = []
        for v in self.fields:
            if v and v.is_validated:
                val = v.getValidator(request)
                if isinstance(val, formencode.Schema):
                    pre_validators += val.pre_validators
                    chained_validators += val.chained_validators
                    val = val.fields

                validators = dict_merge(validators, val)
        return {self.name : formencode.ForEach(BaseSchema(pre_validators=pre_validators, chained_validators=chained_validators, **validators), not_empty = self.attrs.required, convert_to_list = True, if_empty = None)}
Esempio n. 2
0
    def getSchema(cls, request, values):
        pre_validators = list(cls.pre_validators)
        chained_validators = list(cls.chained_validators)

        validators = {}

        for v in cls.fields:
            if v and v.is_validated:
                val = v.getValidator(request)
                if isinstance(val, formencode.Schema):
                    pre_validators += val.pre_validators
                    chained_validators += val.chained_validators
                    val = val.fields

                validators = dict_merge(validators, val)
        for form in cls.extra_forms:
            validators[form.id] = form.getSchema(request)
        return BaseSchema(chained_validators=chained_validators, pre_validators=pre_validators, **validators)
Esempio n. 3
0
 def getValidator(self, request):
     validator = {}
     for w in self.fields:
         if w.name:
             dict_merge(validator, w.getValidator(request))
     return validator
Esempio n. 4
0
 def getValidator(self, request):
     validators = {}
     for v in self.fields:
         if v and v.is_validated:
             validators = dict_merge(validators, v.getValidator(request))
     return {self.name : BaseSchema(**validators)}
Esempio n. 5
0
 def getValidator(self, request):
     validators = {}
     for v in self.fields:
         if v and v.is_validated:
             validators = dict_merge(validators, v.getValidator(request))
     return validators