def clean_destination(self): destination = self.cleaned_data.get("destination") res = clean_destination(User.objects.get(pk=self.data["applier"]), destination) if destination != res: raise forms.ValidationError(res) else: return res
def validate_destination(self, attrs, source): user = self.context.get('request').user destination = attrs.get('destination') res = clean_destination(user, destination) if res != destination: raise serializers.ValidationError(res) return attrs
def validate(self, data): user = self.context.get('request').user # validate source source = data.get('source') res = clean_source(user, source) if res != source: raise serializers.ValidationError(res) # validate destination destination = data.get('destination') res = clean_destination(user, destination) if res != destination: raise serializers.ValidationError(res) # validate expires expires = data.get('expires') res = clean_expires(expires) if res != expires: raise serializers.ValidationError(res) # check if rule already exists with different name fields = { 'source': data.get('source'), 'destination': data.get('destination'), } exists = check_if_rule_exists(fields) if exists: raise serializers.ValidationError(exists) return data
def clean_destination(self): destination = self.cleaned_data.get('destination') res = clean_destination(User.objects.get(pk=self.data['applier']), destination) if destination != res: raise forms.ValidationError(res) else: return res
def validate(self, data): user = self.context.get('request').user # validate source source = data.get('source') res = clean_source( user, source ) if res != source: raise serializers.ValidationError(res) # validate destination destination = data.get('destination') res = clean_destination( user, destination ) if res != destination: raise serializers.ValidationError(res) # validate expires expires = data.get('expires') res = clean_expires( expires ) if res != expires: raise serializers.ValidationError(res) # check if rule already exists with different name fields = { 'source': data.get('source'), 'destination': data.get('destination'), } exists = check_if_rule_exists(fields) if exists: raise serializers.ValidationError(exists) return data