Class: PortalOption

PortalOption()

new PortalOption()

A portal OptionType with a name and one or more string values. See https://github.com/DataONEorg/collections-portals-schemas/blob/1.1.0/schemas/portals.xsd#L725-L754
Since:
  • 2.41.0
Source:

Methods

assertValid()

Require the non-whitespace content specified by NonEmptyStringType.
Source:
Throws:
When the name or a value is empty or only whitespace.
Type
Error

toElement(doc) → {Element}

Create an OptionType XML element in the provided XML document. `mapConfig` values use CDATA because they contain serialized JSON.
Parameters:
Name Type Description
doc XMLDocument Owning XML document.
Source:
Returns:
OptionType XML element.
Type
Element

validate() → {object|null}

Check for non-whitespace content in the option name and values.
Source:
Returns:
Validation errors keyed by property name or `null` when valid.
Type
object | null

findDirectChild(parent, optionName) → {Element|undefined}

Find a direct child option by its exact name.
Parameters:
Name Type Description
parent Element Element containing options.
optionName string Name to find.
Source:
Returns:
Matching option element, if present.
Type
Element | undefined

fromElement(element) → {PortalOption}

Read an OptionType XML element without changing its values' whitespace.
Parameters:
Name Type Description
element Element OptionType XML element.
Source:
Returns:
Parsed option.
Type
PortalOption

PortalOption(data)

new PortalOption(data)

Create an option from its schema values.
Parameters:
Name Type Description
data object Option values.
Properties
Name Type Description
optionName string Nonempty option name.
optionValue Array.<string> Nonempty option values.
Source:

Methods

assertValid()

Require the non-whitespace content specified by NonEmptyStringType.
Source:
Throws:
When the name or a value is empty or only whitespace.
Type
Error

toElement(doc) → {Element}

Create an OptionType XML element in the provided XML document. `mapConfig` values use CDATA because they contain serialized JSON.
Parameters:
Name Type Description
doc XMLDocument Owning XML document.
Source:
Returns:
OptionType XML element.
Type
Element

validate() → {object|null}

Check for non-whitespace content in the option name and values.
Source:
Returns:
Validation errors keyed by property name or `null` when valid.
Type
object | null

findDirectChild(parent, optionName) → {Element|undefined}

Find a direct child option by its exact name.
Parameters:
Name Type Description
parent Element Element containing options.
optionName string Name to find.
Source:
Returns:
Matching option element, if present.
Type
Element | undefined

fromElement(element) → {PortalOption}

Read an OptionType XML element without changing its values' whitespace.
Parameters:
Name Type Description
element Element OptionType XML element.
Source:
Returns:
Parsed option.
Type
PortalOption