evennia.utils.validatorfuncs

Contains all the validation functions.

All validation functions must have a checker (probably a session) and entry arg.

They can employ more paramters at your leisure.

evennia.utils.validatorfuncs.text(entry, option_key='Text', **kwargs)[source]
evennia.utils.validatorfuncs.color(entry, option_key='Color', **kwargs)[source]

The color should be just a color character, so ‘r’ if red color is desired.

evennia.utils.validatorfuncs.datetime(entry, option_key='Datetime', account=None, from_tz=None, **kwargs)[source]

Process a datetime string in standard forms while accounting for the inputer’s timezone. Always returns a result in UTC.

Parameters
  • entry (str) – A date string from a user.

  • option_key (str) – Name to display this datetime as.

  • account (AccountDB) – The Account performing this lookup. Unless from_tz is provided, the account’s timezone option will be used.

  • from_tz (pytz.timezone) – An instance of a pytz timezone object from the user. If not provided, tries to use the timezone option of account. If neither one is provided, defaults to UTC.

Returns

datetime in UTC.

Raises

ValueError – If encountering a malformed timezone, date string or other format error.

evennia.utils.validatorfuncs.duration(entry, option_key='Duration', **kwargs)[source]

Take a string and derive a datetime timedelta from it.

Parameters
  • entry (string) – This is a string from user-input. The intended format is, for example: “5d 2w 90s” for ‘five days, two weeks, and ninety seconds.’ Invalid sections are ignored.

  • option_key (str) – Name to display this query as.

Returns

timedelta

evennia.utils.validatorfuncs.future(entry, option_key='Future Datetime', from_tz=None, **kwargs)[source]
evennia.utils.validatorfuncs.signed_integer(entry, option_key='Signed Integer', **kwargs)[source]
evennia.utils.validatorfuncs.positive_integer(entry, option_key='Positive Integer', **kwargs)[source]
evennia.utils.validatorfuncs.unsigned_integer(entry, option_key='Unsigned Integer', **kwargs)[source]
evennia.utils.validatorfuncs.boolean(entry, option_key='True/False', **kwargs)[source]

Simplest check in computer logic, right? This will take user input to flick the switch on or off

Parameters
  • entry (str) – A value such as True, On, Enabled, Disabled, False, 0, or 1.

  • option_key (str) – What kind of Boolean we are setting. What Option is this for?

Returns

Boolean

evennia.utils.validatorfuncs.timezone(entry, option_key='Timezone', **kwargs)[source]

Takes user input as string, and partial matches a Timezone.

Parameters
  • entry (str) – The name of the Timezone.

  • option_key (str) – What this Timezone is used for.

Returns

A PYTZ timezone.

evennia.utils.validatorfuncs.email(entry, option_key='Email Address', **kwargs)[source]
evennia.utils.validatorfuncs.lock(entry, option_key='locks', access_options=None, **kwargs)[source]