def validate_postal_code(self, attrs, source): value = attrs[source] if value: country_code = '' if 'country' in attrs: country_code = attrs['country'] elif self.object: country_code = self.object.country if country_code: validate_postal_code(value, country_code) return attrs
def validate_postal_code(self, attrs, source): if source in attrs: value = attrs[source] country_code = '' if 'address.country.alpha2_code' in attrs: country_code = attrs['address.country.alpha2_code'] elif self.object and self.object.address and self.object.address.country: country_code = self.object.address.country.alpha2_code if country_code: validate_postal_code(value, country_code) return attrs
def validate_postal_code(self, attrs, source): value = attrs[source] if value: country_code = "" if "country" in attrs: country_code = attrs["country"] elif self.object and self.object.country: country_code = self.object.country.alpha2_code if country_code: validate_postal_code(value, country_code) return attrs