Field » value

value() → value or null
value(options) → value or null
value(loader) → value or null
value(loader, options) → value or null

Retrieve the value of a Field, optionally passing it through a loader function and/or supplying options.

enoflag color: beige
towel color:
|
javascriptconst document = eno.parse(input);

const flagColor = document.element('flag color');
const towelColor = document.element('towel color');

flagColor.value();  // returns 'beige'
towelColor.value();  // returns null

flagColor.value(({ value }) => value.replace('eig', 'lu'));  // returns 'blue'

Parameters

loader

A function returning the transformed/validated value or throwing an error.The function is passed name and value inside a single object parameter.

options

enforceValue

Whether there must be a value or the field is allowed to be empty (default to false)

required

Alias for enforceValue (this exists on many methods and depending on context refers to either element or value)

Return value

The (optionally transformed/validated) value of this Field.