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

Method validateDelimiterValue

src/Encoder/Bootstring.js:508–532  ·  view source on GitHub ↗

* Validates the delimiter value. * @param {Chain} value Delimiter value * @param {Field} setting Sender field * @return {boolean|object}

(value, setting)

Source from the content-addressed store, hash-verified

506 * @return {boolean|object}
507 */
508 validateDelimiterValue (value, setting) {
509 // The delimiter value depends on the basic range and the digit mapping
510 if (!this.isSettingValid('basicRangeStart', 'basicRangeEnd', 'digitMapping')) {
511 return false
512 }
513
514 const { basicRangeStart, basicRangeEnd, digitMapping } =
515 this.getSettingValues()
516
517 const delimiter = value.getCodePointAt(0)
518
519 // Delimiter needs to be in the basic code point range
520 if (delimiter < basicRangeStart ||
521 delimiter > basicRangeEnd ||
522 digitMapping.indexOfCodePoint(delimiter) !== -1) {
523 return {
524 key: 'bootstringDelimiterInvalid',
525 message:
526 'The value must be part of the basic code point range while ' +
527 'not having a digit mapped to it'
528 }
529 }
530
531 return true
532 }
533
534 /**
535 * Validates initial bias setting value according to section 4 of RFC 3492

Callers

nothing calls this directly

Calls 4

isSettingValidMethod · 0.80
getSettingValuesMethod · 0.80
getCodePointAtMethod · 0.80
indexOfCodePointMethod · 0.80

Tested by

no test coverage detected