Fields

Intro

Field definitions passed from the agent back to hydra.

Most fields derive from TextField, defined as follows:

TextField

class lerna.fields.TextField(_optional=False, _description=None, **properties)[source]

A generic text field.

generate()

Generate a random value that satisifies this SchemaLike.

Note

Certain SchemaLikes may break this invariant if it isn’t feasible to automatically generate valid data.

lookup_name(default=None)

Look up this instance’s virtual name, falling back to its attribute name and then to default.

Parameters:default (str) – The default value to return when this instance doesn’t define a virtual name AND when it’s not a part of a larger schema (where it would get assigned the same name as its attribute name automatically).
Returns:The name.
Return type:str
materialize(sparse=False)

Materializes this Schema into a dictionary recursively.

Parameters:sparse (bool) – Controls whether or not null properties should be included in the result.
Returns:The dictionary representation of this instance.
Return type:dict
update(data)

Validate data against this Schema and set its properties to the appropriate values from the data dictionary on succcess.

Raises:ValidationError – If data fails to Schema.validate().
Parameters:data (dict) –
Returns:On success.
Return type:None
validate(data)

Validate data against this Schema.

Raises:ValidationError – When the dictionary fails to validate.
Parameters:data (dict) –
Returns:On success.
Return type:None
value = None

The field’s default value. Optional.

virtualize()

The virtual representation of a Schema is that Schema.

When converting from specific field types to JSON, a wrapper function is usually used to first wrap in a Field, which can then be materialized to an entity:

Field

class lerna.fields.Field(_optional=False, _description=None, **properties)[source]
field = None

A map containing the field’s properties defined in the field class described by kind.

generate()

Generate a random value that satisifies this SchemaLike.

Note

Certain SchemaLikes may break this invariant if it isn’t feasible to automatically generate valid data.

kind = None

The class name of the exact kind of field, as a string.

lookup_name(default=None)

Look up this instance’s virtual name, falling back to its attribute name and then to default.

Parameters:default (str) – The default value to return when this instance doesn’t define a virtual name AND when it’s not a part of a larger schema (where it would get assigned the same name as its attribute name automatically).
Returns:The name.
Return type:str
materialize(sparse=False)[source]

Materialize, setting autocomplete value before returning.

Parameters:sparse (bool) – Controls whether or not null properties should be included in the result.
Returns:The dictionary representation of this instance.
Return type:dict
(An alternative way to do this might be to make a special kind of
Property for autocomplete)
update(data)

Validate data against this Schema and set its properties to the appropriate values from the data dictionary on succcess.

Raises:ValidationError – If data fails to Schema.validate().
Parameters:data (dict) –
Returns:On success.
Return type:None
validate(data)

Validate data against this Schema.

Raises:ValidationError – When the dictionary fails to validate.
Parameters:data (dict) –
Returns:On success.
Return type:None
virtualize()

The virtual representation of a Schema is that Schema.

There are many kinds of fields available, including things like FirstNameField, NumberField, and so on. See the full list of fields for details.

Module docs

General, standardized definitions for form data.

Used for standardizing data from various sources with one “schema.” The fields are described through meta classes: description, field data structure, regex.

Autocomplete values inserted from sheet at: https://docs.google.com/a/ave81.com/spreadsheets/d/1qpPtPvbFTGKrBMxTjYIWERv8zmEPR0dNc4x31IS00ZM/edit?usp=sharing

class lerna.fields.AddressCityField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing the city identifier of a user’s address.

AUTOCOMPLETE = 'address-level2'
class lerna.fields.AddressCountryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing the country identifier of a user’s address. The values of these fields are free-form text, see AddressStrictCountryField for a more restrictive representation of country fields.

AUTOCOMPLETE = 'country-name'
class lerna.fields.AddressPostalCodeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PostalCodeField

A text field representing the postal code identifier of a user’s address.

AUTOCOMPLETE = 'postal-code'
class lerna.fields.AddressStateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing the state identifier of a user’s address.

AUTOCOMPLETE = 'address-level1'
class lerna.fields.AddressStreetField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing the street identifier of a user’s address.

AUTOCOMPLETE = 'street-address'
class lerna.fields.AddressStrictCountryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.SelectField

A choice field representing the set of countries defined by ISO3166-2. These fields’ values must be in ISO3166-2 alpha-2 format.

AUTOCOMPLETE = 'country'
class lerna.fields.AddressStrictStateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.SelectField

A choice field representing the set of country subdivisions defined by ISO3166-2.

AUTOCOMPLETE = 'address-level1'
class lerna.fields.AgeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A text field representing a user’s age.

class lerna.fields.AnnualRevenueField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.CurrencyField

A currency field representing a user’s annual revenue.

class lerna.fields.BillingAddressCityField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressCityField

A text field representing the city identifier of a user’s billing address.

AUTOCOMPLETE = 'billing address-level2'
class lerna.fields.BillingAddressCountryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressCountryField

A text field representing the country identifier of a user’s billing address.

AUTOCOMPLETE = 'billing country-name'
class lerna.fields.BillingAddressPostalCodeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressPostalCodeField

A text field representing the postal code identifier of a user’s billing address.

AUTOCOMPLETE = 'billing postal-code'
class lerna.fields.BillingAddressStateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStateField

A text field representing the state identifier of a user’s billing address.

AUTOCOMPLETE = 'billing address-level1'
class lerna.fields.BillingAddressStreetField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStreetField

A text field representing the street identifier of a user’s billing address.

AUTOCOMPLETE = 'billing street-address'
class lerna.fields.BillingAddressStrictCountryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStrictCountryField

A billing address version of the AddressStrictCountryField.

AUTOCOMPLETE = 'billing country'
class lerna.fields.BillingAddressStrictStateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStrictStateField

A billing address version of the AddressStrictStateField.

AUTOCOMPLETE = 'billing address-level1'
class lerna.fields.BirthdateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.DateField

A text field representing a user’s birth _date_.

AUTOCOMPLETE = 'bday'
class lerna.fields.BirthdayField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.DayField

A text field representing a user’s birth _day_.

class lerna.fields.CenterViewerUUIDField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.HiddenField

The UUID of a viewer (visitor) on a website on which the Center tracking code is installed.

class lerna.fields.CheckBoxField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields._BaseField

A generic checkbox field.

checked = None

Represents whether or not the value should be inspected.

value = None

A value that will get sent through when checked is True.

class lerna.fields.ChoiceField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields._BaseField

A generic field representing a single choice of a number of choices.

value = None

Represents the default choice (by its value).

values = None

This represents the possible choices for this field’s value.

class lerna.fields.CommentField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextAreaField

A generic comment field.

class lerna.fields.CompanyField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s company.

AUTOCOMPLETE = 'organization'
class lerna.fields.CouponAmountField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PaymentAmountField

A field representing a coupon value (usually subtracted from the item’s original price). See PaymentAmountField.

class lerna.fields.CurrencyField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic field representing some currency in any format.

AUTOCOMPLETE = 'transaction-currency'
class lerna.fields.DateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a date.

value = None

Date field values are in YYYY-MM-DD format.

class lerna.fields.DateTimeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a date and time.

value = None

SS+HH:mm`` format.

Type:Date time field values are in ``YYYY-MM-DDTHH
Type:mm
class lerna.fields.DayField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a day of the year.

value = None

Day field values are in MM-DD format.

class lerna.fields.DurationMinutesField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

A duration expressed in seconds but which should be displayed as a pair of minute and second inputs.

class lerna.fields.EmailField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic e-mail address field.

AUTOCOMPLETE = 'email'
class lerna.fields.FacebookUserHandleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.UserHandleField

A user’s Facebook username.

class lerna.fields.FaxNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PhoneNumberField

A text field representing a user’s fax number.

AUTOCOMPLETE = 'fax tel'
class lerna.fields.Field(_optional=False, _description=None, **properties)[source]

Bases: req.schema.schema.Schema

field = None

A map containing the field’s properties defined in the field class described by kind.

kind = None

The class name of the exact kind of field, as a string.

materialize(sparse=False)[source]

Materialize, setting autocomplete value before returning.

Parameters:sparse (bool) – Controls whether or not null properties should be included in the result.
Returns:The dictionary representation of this instance.
Return type:dict
(An alternative way to do this might be to make a special kind of
Property for autocomplete)
class lerna.fields.FirstNameField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s first name.

AUTOCOMPLETE = 'given-name'
class lerna.fields.FullNameField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s full name.

AUTOCOMPLETE = 'name'
class lerna.fields.GeographicElevationField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A geographic elevation relative to Mean Sea Level.

class lerna.fields.GeographicLatitudeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A geographic latitude in the WGS84 spatial reference system.

class lerna.fields.GeographicLongitudeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A geographic longitude in the WGS84 spatial reference system.

class lerna.fields.GooglePlusUserHandleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.UserHandleField

A user’s Google Plus username.

class lerna.fields.HiddenField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A hidden text field.

class lerna.fields.HiddenMultiSelectField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.MultiSelectField

A hidden field containing a list of values.

This should be literally a MultiSelectField, but hidden.

Differs from a HiddenField, which only has one value, and a MultiSelectField by being hidden.

class lerna.fields.HiddenMultiTagField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.MultiTagField

A hidden field representing 0 or more tags.

This should be literally a MultiTagField, but hidden.

Differs from a HiddenField, which only has one value, and a MultiTagField by being hidden.

class lerna.fields.HomeFaxNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.FaxNumberField

A text field representing a user’s home fax number.

AUTOCOMPLETE = 'fax tel'
class lerna.fields.HomePhoneNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PhoneNumberField

A text field representing a user’s home phone number.

AUTOCOMPLETE = 'home tel'
class lerna.fields.IPAddressField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text field representing an IPv4 or IPv6 address.

class lerna.fields.IPv4AddressField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text field representing an IPv4 address.

class lerna.fields.IPv6AddressField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text field representing an IPv6 address.

class lerna.fields.IndustryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s industry.

class lerna.fields.IntegerField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A generic numeric field.

max_value = None

The maximum numeric value that this field can contain.

min_value = None

The minimum numeric value that this field can contain.

step = None

Specifies the legal number intervals for this field.

value = None

A number representing this field’s default value.

class lerna.fields.JobTitleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s job title.

AUTOCOMPLETE = 'organization-title'
class lerna.fields.LastNameField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s last name.

AUTOCOMPLETE = 'family-name'
class lerna.fields.LeadScoreField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

A score ranking a lead relative to other leads.

class lerna.fields.LifetimeValueField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

A field representing a contact’s lifetime value as a multiple of a currency’s atomic units. For example, for USD this would represent some number of cents. The currency may be specified as a separate (CurrencyField or StrictCurrencyField) field.

class lerna.fields.LinkedInUserHandleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.UserHandleField

A user’s LinkedIn username.

class lerna.fields.LocaleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic field representing a locale in any format.

AUTOCOMPLETE = 'language'
class lerna.fields.MiddleNameField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s middle name.

AUTOCOMPLETE = 'additional-name'
class lerna.fields.MobilePhoneNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PhoneNumberField

A text field representing a user’s mobile/cell phone number.

AUTOCOMPLETE = 'mobile tel'
class lerna.fields.MultiSelectField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields._BaseField

A field representing multiple choice select.

Differs from a SelectField in that SelectField may have only one selection (of the available choices), whereas a MultiSelectField may have multiple choices selected for its value.

value = None

This represents the default selected possible value(s) for this field’s value.

values = None

This represents the possible values this field can have (any number of).

class lerna.fields.MultiTagField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields._BaseField

A field representing 0 or more tags.

selected = None

This represents the selected tags for this field

values = None

This represents the possible tags for this field’s values.

class lerna.fields.NumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic numeric field.

max_value = None

The maximum numeric value that this field can contain.

min_value = None

The minimum numeric value that this field can contain.

step = None

Specifies the legal number intervals for this field.

value = None

A number representing this field’s default value.

class lerna.fields.NumberOfEmployeesField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A numeric field representing a company’s employee count.

class lerna.fields.PasswordField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic password field.

class lerna.fields.PathField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text field representing the path portion of a URI.

class lerna.fields.PaymentAmountField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

A field representing a payment amount as a multiple of a currency’s atomic units. For example, for USD this would represent some number of cents. The currency may be specified as a separate (CurrencyField or StrictCurrencyField) field.

class lerna.fields.PercentageField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.NumberField

A generic field representing a percentage.

value = None

A number representing a percentage.

class lerna.fields.PhoneNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a user’s phone number.

AUTOCOMPLETE = 'tel'
class lerna.fields.PostalCodeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

An integer field representing a zip/postal code.

AUTOCOMPLETE = 'postal-code'
class lerna.fields.RadioField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.ChoiceField

A field representing multiple linked radio buttons.

class lerna.fields.RatingField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

A rating on a scale from min_value to max_value.

class lerna.fields.ReadOnlyField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A read only field. Must contain a default value.

value = None

The field’s value.

class lerna.fields.RefundAmountField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PaymentAmountField

A field representing a refund. See PaymentAmountField.

class lerna.fields.SalutationField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.ChoiceField

A single choice field representing a user’s salutation.

AUTOCOMPLETE = 'honorific-prefix'
class lerna.fields.SelectField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.ChoiceField

A generic select field.

class lerna.fields.ShippingAddressCityField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressCityField

A text field representing the city identifier of a user’s shipping address.

AUTOCOMPLETE = 'shipping address-level2'
class lerna.fields.ShippingAddressCountryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressCountryField

A text field representing the country identifier of a user’s shipping address.

AUTOCOMPLETE = 'shipping country-name'
class lerna.fields.ShippingAddressPostalCodeField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressPostalCodeField

A text field representing the postal code identifier of a user’s shipping address.

AUTOCOMPLETE = 'shipping postal-code'
class lerna.fields.ShippingAddressStateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStateField

A text field representing the state identifier of a user’s shipping address.

AUTOCOMPLETE = 'shipping address-level1'
class lerna.fields.ShippingAddressStreetField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStreetField

A text field representing the street identifier of a user’s shipping address.

AUTOCOMPLETE = 'shipping street-address'
class lerna.fields.ShippingAddressStrictCountryField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStrictCountryField

A shipping address version of the AddressStrictCountryField.

AUTOCOMPLETE = 'shipping country'
class lerna.fields.ShippingAddressStrictStateField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.AddressStrictStateField

A shipping address version of the AddressStrictStateField.

AUTOCOMPLETE = 'shipping address-level1'
class lerna.fields.StrictCurrencyField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.ChoiceField

A choice field representing the set of 3-letter currency codes defined by ISO4217.

class lerna.fields.StrictLocaleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.ChoiceField

A choice field representing the set of language codes as defined by ISO639/BCP47.

class lerna.fields.SystemHiddenField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.HiddenField

A hidden text field reserved for system use.

This should be retained everywhere normal HiddenFields are, but generally should not be displayed to, or made editable by, users.

class lerna.fields.TagField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing a single tag.

class lerna.fields.TextAreaField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text area field.

class lerna.fields.TextField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields._BaseField

A generic text field.

value = None

The field’s default value. Optional.

class lerna.fields.TimezoneOffsetField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A text field representing an ISO 8601 timezone offset.

value = None

mm``, ±hhmm, or ±hh format, or Z.

Type:Timezone offset values are in ``±hh
class lerna.fields.TwitterUserHandleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.UserHandleField

A user’s Twitter handle.

class lerna.fields.URIField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text field representing a URI.

class lerna.fields.UserAgentField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A generic text field representing a user agent.

class lerna.fields.UserHandleField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.TextField

A user’s handle or username on a website.

class lerna.fields.ViewportHeightField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

The vertical number of pixels in a viewport (screen, window, etc.).

class lerna.fields.ViewportWidthField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.IntegerField

The horizontal number of pixels in a viewport (screen, window, etc.).

class lerna.fields.WebsiteField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.URIField

A URI field representing a user’s website.

AUTOCOMPLETE = 'url'
class lerna.fields.WorkFaxNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.FaxNumberField

A text field representing a user’s work fax number.

AUTOCOMPLETE = 'fax tel'
class lerna.fields.WorkPhoneNumberField(_optional=False, _description=None, **properties)[source]

Bases: lerna.fields.PhoneNumberField

A text field representing a user’s work phone number.

AUTOCOMPLETE = 'work tel'
lerna.fields.clazz

alias of lerna.fields.FacebookUserHandleField