1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Same for ValueMixin

This commit is contained in:
Ross McFarland
2018-11-30 08:35:56 -08:00
parent c9b373f0ae
commit a29f188bc0

View File

@@ -366,17 +366,7 @@ class _ValueMixin(object):
@classmethod
def validate(cls, name, data):
reasons = super(_ValueMixin, cls).validate(name, data)
value = None
try:
value = data['value']
if value == '':
reasons.append('empty value')
elif value is None:
reasons.append('missing value')
except KeyError:
reasons.append('missing value')
if value:
reasons.extend(cls._value_type.validate(value, cls))
reasons.extend(cls._value_type.validate(data.get('value', None), cls))
return reasons
def __init__(self, zone, name, data, source=None):
@@ -472,7 +462,11 @@ class _TargetValue(object):
@classmethod
def validate(cls, data, record_cls):
reasons = []
if not data.endswith('.'):
if data == '':
reasons.append('empty value')
elif not data:
reasons.append('missing value')
elif not data.endswith('.'):
reasons.append('{} value "{}" missing trailing .'
.format(record_cls._type, data))
return reasons