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

Method validateTimingMarkSettingValue

src/Encoder/MorseCode.js:292–307  ·  view source on GitHub ↗

* Validates timing mark setting value. * Makes sure they can be differentiated from each other. * @protected * @param {mixed} rawValue * @param {Setting} setting * @return {boolean} Returns true, if value is valid.

(rawValue, setting)

Source from the content-addressed store, hash-verified

290 * @return {boolean} Returns true, if value is valid.
291 */
292 validateTimingMarkSettingValue (rawValue, setting) {
293 const mark = setting.filterValue(rawValue)
294 const equalSettingName =
295 ['signalOnMark', 'signalOffMark']
296 .filter(name => name !== setting.getName())
297 .find(name => mark.indexOf(this.getSettingValue(name)) === 0)
298
299 if (equalSettingName !== undefined) {
300 return {
301 key: 'morseCodeMarkNotUnique',
302 message: 'Timing marks need to be different from each other'
303 }
304 }
305
306 return true
307 }
308
309 /**
310 * Triggered when a setting field has changed.

Callers

nothing calls this directly

Calls 4

indexOfMethod · 0.80
getSettingValueMethod · 0.80
filterValueMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected