'we can\'t tell that everything is of the right type until we have
all the variables.  Run basic types (from isa) as well as
any _post_validate_<foo> functions.'

def post_validate(self, templar):

    omit_value = templar._available_variables.get('omit')
    for (name, attribute) in iteritems(self._valid_attrs):
        if (getattr(self, name) is None):
            if (not attribute.required):
                continue
            else:
                raise AnsibleParserError(("the    field    '%s'    is    required    but    was    not    set" % name))
        elif ((not attribute.always_post_validate) and (self.__class__.__name__ not in ('Task', 'Handler', 'PlayContext'))):
            continue
        try:
            method = getattr(self, ('_post_validate_%s' % name), None)
            if method:
                value = method(attribute, getattr(self, name), templar)
            elif (attribute.isa == 'class'):
                value = getattr(self, name)
            else:
                value = templar.template(getattr(self, name))
            if ((omit_value is not None) and (value == omit_value)):
                setattr(self, name, attribute.default)
                continue
            if (value is not None):
                if (attribute.isa == 'string'):
                    value = to_text(value)
                elif (attribute.isa == 'int'):
                    value = int(value)
                elif (attribute.isa == 'float'):
                    value = float(value)
                elif (attribute.isa == 'bool'):
                    value = boolean(value, strict=False)
                elif (attribute.isa == 'percent'):
                    if (isinstance(value, string_types) and ('%' in value)):
                        value = value.replace('%', '')
                    value = float(value)
                elif (attribute.isa in ('list', 'barelist')):
                    if (value is None):
                        value = []
                    elif (not isinstance(value, list)):
                        if (isinstance(value, string_types) and (attribute.isa == 'barelist')):
                            display.deprecated('Using    comma    separated    values    for    a    list    has    been    deprecated.    You    should    instead    use    the    correct    YAML    syntax    for    lists.    ')
                            value = value.split(',')
                        else:
                            value = [value]
                    if (attribute.listof is not None):
                        for item in value:
                            if (not isinstance(item, attribute.listof)):
                                raise AnsibleParserError(("the    field    '%s'    should    be    a    list    of    %s,    but    the    item    '%s'    is    a    %s" % (name, attribute.listof, item, type(item))), obj=self.get_ds())
                            elif (attribute.required and (attribute.listof == string_types)):
                                if ((item is None) or (item.strip() == '')):
                                    raise AnsibleParserError(("the    field    '%s'    is    required,    and    cannot    have    empty    values" % (name,)), obj=self.get_ds())
                elif (attribute.isa == 'set'):
                    if (value is None):
                        value = set()
                    elif (not isinstance(value, (list, set))):
                        if isinstance(value, string_types):
                            value = value.split(',')
                        else:
                            value = [value]
                    if (not isinstance(value, set)):
                        value = set(value)
                elif (attribute.isa == 'dict'):
                    if (value is None):
                        value = dict()
                    elif (not isinstance(value, dict)):
                        raise TypeError(('%s    is    not    a    dictionary' % value))
                elif (attribute.isa == 'class'):
                    if (not isinstance(value, attribute.class_type)):
                        raise TypeError(('%s    is    not    a    valid    %s    (got    a    %s    instead)' % (name, attribute.class_type, type(value))))
                    value.post_validate(templar=templar)
            setattr(self, name, value)
        except (TypeError, ValueError) as e:
            raise AnsibleParserError(("the    field    '%s'    has    an    invalid    value    (%s),    and    could    not    be    converted    to    an    %s.The    error    was:    %s" % (name, value, attribute.isa, e)), obj=self.get_ds(), orig_exc=e)
        except (AnsibleUndefinedVariable, UndefinedError) as e:
            if (templar._fail_on_undefined_errors and (name != 'name')):
                raise AnsibleParserError(("the    field    '%s'    has    an    invalid    value,    which    appears    to    include    a    variable    that    is    undefined.The    error    was:    %s" % (name, e)), obj=self.get_ds(), orig_exc=e)
    self._finalized = True
