'Validate if `autoname` property is correctly set.'

def validate_series(self, autoname=None, name=None):

    if (not autoname):
        autoname = self.autoname
    if (not name):
        name = self.name
    if ((not autoname) and self.get(u'fields', {u'fieldname': u'naming_series'})):
        self.autoname = u'naming_series:'
    if (autoname and autoname.startswith(u'field:')):
        field = autoname.split(u':')[1]
        if ((not field) or (field not in [df.fieldname for df in self.fields])):
            frappe.throw(_(u"Invalid    fieldname    '{0}'    in    autoname".format(field)))
    if (autoname and (not autoname.startswith(u'field:')) and (not autoname.startswith(u'eval:')) and (not (autoname.lower() in (u'prompt', u'hash'))) and (not autoname.startswith(u'naming_series:'))):
        prefix = autoname.split(u'.')[0]
        used_in = frappe.db.sql(u'select    name    from    tabDocType    where    substring_index(autoname,    ".",    1)    =    %s    and    name!=%s', (prefix, name))
        if used_in:
            frappe.throw(_(u'Series    {0}    already    used    in    {1}').format(prefix, used_in[0][0]))
