* Validates code 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)
| 255 | * @return {boolean} Returns true, if value is valid. |
| 256 | */ |
| 257 | validateCodeMarkSettingValue (rawValue, setting) { |
| 258 | const mark = setting.filterValue(rawValue) |
| 259 | |
| 260 | // Because morse code letters are separated by whitespaces they |
| 261 | // are not allowed inside morse code marks |
| 262 | if (mark.match(/\s/) !== null) { |
| 263 | return { |
| 264 | key: 'morseCodeMarkWhitespaceNotAllowed', |
| 265 | message: 'Whitespaces are not allowed inside morse code marks' |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | const equalSettingName = |
| 270 | ['shortMark', 'longerMark', 'spaceMark'] |
| 271 | .filter(name => name !== setting.getName()) |
| 272 | .find(name => mark.isEqualTo(this.getSettingValue(name))) |
| 273 | |
| 274 | if (equalSettingName !== undefined) { |
| 275 | return { |
| 276 | key: 'morseCodeMarkNotUnique', |
| 277 | message: 'Morse code marks need to be different from each other' |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | return true |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Validates timing mark setting value. |
nothing calls this directly
no test coverage detected