Method code for $registry.valid_name()

[Turn on line numbering]
arg name;
var word, sname, matched_obj, m;

// returns 1 if the name is valid
/// if (!.has_flag('variables,sender()))
//    throw(~perm, "Database is not readable by sender.");
(> .perms(caller(), 'trusts) <);

// check name itself first
sname = .strip_key(name);
if (max_word_len && listlen(name.explode()) > max_word_len)
    throw(~invname, "Names can only be " + max_word_len + " words long.");
if (min_char_len && strlen(sname) < min_char_len)
    throw(~invname, "Names must have at least " + min_char_len + " alpha-numeric characters in them");
if (max_char_len && name.length() > max_char_len)
    throw(~invname, "Names can only be " + max_char_len + " characters long.");

// see if it already exists
if ((| (matched_obj = .exact_match(name)) |)) {
    if (matched_obj != sender())
        throw(~invname, "The name \"" + name + "\" conflicts with the existing user \"" + matched_obj.name() + "\"");
}

// check reserved and invalid names
if (sname in .reserved_names())
    throw(~invname, "`" + name + "' is a reserved name.");
if (invalid_names && (m = regexp(sname, invalid_names)))
    throw(~invname, "`" + m[2] + "' is not allowed as part of a name.");

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon