MCPcopy Create free account
hub / github.com/cryptii/cryptii / constructor

Method constructor

src/Field.js:33–57  ·  view source on GitHub ↗

* Constructor * @param {string} name Field name; expected to be camel cased * @param {object} [spec] Field spec * @param {string} [spec.label] Field label, defaults to title cased name * @param {mixed} [spec.value] Default field value * @param {object} [spec.delegate] Field delegate

(name, spec = {})

Source from the content-addressed store, hash-verified

31 * gets requested, returns randomly chosen value.
32 */
33 constructor (name, spec = {}) {
34 super()
35 this._viewPrototype = FieldView
36
37 this._name = name
38 this._value = spec.value !== undefined ? spec.value : null
39 this._delegate = spec.delegate || null
40 this._randomizable = spec.randomizable !== false
41
42 // Validation
43 this._valid = true
44 this._message = null
45 this._messageKey = null
46
47 // Custom validate, filter and randomize functions
48 this._validateValueCallback = spec.validateValue || null
49 this._filterValueCallback = spec.filterValue || null
50 this._randomizeValueCallback = spec.randomizeValue || null
51
52 // View related properties
53 this._label = spec.label || StringUtil.camelCaseToRegular(name)
54 this._visible = spec.visible !== false
55 this._priority = spec.priority !== undefined ? spec.priority : 0
56 this._width = spec.width || 12
57 }
58
59 /**
60 * Returns field name.

Callers

nothing calls this directly

Calls 1

camelCaseToRegularMethod · 0.80

Tested by

no test coverage detected