String

Property Type: string

Strings represent a text value and can be configured with validators to limit input using regular expressions, and to enforce minimum and maximum lengths.

Property Options

NameTypeDefaultDescription
trimbooleanfalseTrims the input string prior to validation but after writers.
lowercasebooleanfalseLowercase the input string prior to validation but after writers.
uppercasebooleanfalseUppercase the input string prior to validation but after writers.
localizationdocument

String localization options.

Note: Although query matching for localized string values is possible, some cases (like $elemMatch) are not supported.

localization.enabledbooleanfalse

Enable localization for the string values. Reading and writing to the property occurs on the current locale or the options below.

When any string in an object definition is localized, a locales property document appears in the instance. Inside it, each localized string property is represented by an array of documents containing each locale and value that have been written ({locale: 'en_US', value: 'foo'}).

Note: Once enabled, localization on a string cannot be disabled.

localization.validstring[][]Limits writing to a set of locales. Leaving this empty allows all org-level valid locales.
localization.fixedstring''Limit the native string property to reading and writing this locale. For reading, the fallback option still applies.
localization.strictbooleantrueFor reading and writing, throw an error if the selected locale is invalid. When false, the fallback option is used to attempt to return a fallback value.
localization.fallbackbooleantrueFor reading, fallback to any usable locale value when none exists for the requested locale.
localization.acldocument[][]A set of acl entries to apply to direct reading and writing of the locales-prefixed string property document array.
localization.readAccessnumber4 (read)The resolved access level required to read the locales-prefixed property document array.
localization.writeAccessnumber6 (update)The resolved access level required to update the locales-prefixed property document array.
localization.aclOverridebooleanfalseWhen true, the acl entries that are applied to the locales-prefixed property document array are applied from scratch to the caller, instead of augmenting their current access level.

Property Validators

Required
name: required

String Validator
name: string
definition:

NameTypeDefaultDescription
mininteger0Minimum length of string
maxintegerMaximum length of string
allowNullbooleanfalseAllow null values
allowEmptybooleanfalseAllow 0-length strings

Printable String Validator
name: printableString
definition:

NameTypeDefaultDescription
anyFirstLetterbooleantrueAllow the first letter of the string to be non-alphanumeric.
allowNumberAsFirstLetterbooleantrueAllows a number as the first letter of the string.
mininteger0min length
maxintegermax length

String Enum Validator
name: stringEnum
definition:

NameTypeDefaultDescription
valuesarrayAn array of possible entries.

Email Validator
name: email
definition:

NameTypeDefaultDescription
allowNullbooleantrueAllow blank or null entries

Locale Validator
name: locale
definition:

NameTypeDefaultDescription
allowNullbooleanfalseAllow blank or null entries

Password Strength Validator
name: passwordStrength
definition:

NameTypeDefaultDescription
minScoreintegerThe minimum password score requirement (based on zxcvbn)

Phone Number Strength Validator
name: phoneNumber
definition:

NameTypeDefaultDescription
allowNullbooleanfalseAllow null entries.
requireMobilebooleanfalseIf true, requires the number to be a mobile number.
allowedCountriesarray or stringsList of allowed countries

URL Validator
name: url
definition:

NameTypeDefaultDescription
allowNullbooleanfalseAllow null values
allowEmptybooleanfalseAllow 0-length strings
webOnlybooleantrueUrl must be a web url, beginning with http:// or https://
webSecurebooleanApplies when webOnly is true. If present, url must either be https:// (true) or http:// (false). Omitting this property allows either.

Pattern Validator
name: pattern
definition:

NameTypeDefaultDescription
allowNullbooleanfalseAllow null values
allowEmptybooleanfalseAllow 0-length strings
patternregexThe regex pattern to test against the incoming string value