* Validates initial bias setting value according to section 4 of RFC 3492 * such that `initial_bias mod base <= base - tmin`. * @param {number} value Initial bias to be validated * @param {Field} setting Sender field * @return {boolean|object}
(value, setting)
| 539 | * @return {boolean|object} |
| 540 | */ |
| 541 | validateInitialBiasValue (value, setting) { |
| 542 | // Can't validate initial bias without valid base and tmin values |
| 543 | if (!this.isSettingValid('digitMapping', 'tmin')) { |
| 544 | return false |
| 545 | } |
| 546 | |
| 547 | const base = this.getSettingValue('digitMapping').getLength() |
| 548 | const tmin = this.getSettingValue('tmin') |
| 549 | |
| 550 | if (MathUtil.mod(value, base) > base - tmin) { |
| 551 | return { |
| 552 | key: 'bootstringInitialBiasInvalid', |
| 553 | message: |
| 554 | 'The value must be chosen such that ' + |
| 555 | 'initial_bias mod base <= base - tmin' |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | return true |
| 560 | } |
| 561 | } |
nothing calls this directly
no test coverage detected