From e350609a765baa986304700cc1d6d89380888d5b Mon Sep 17 00:00:00 2001 From: James Buck Date: Tue, 19 Jan 2021 20:30:39 +0000 Subject: [PATCH] Fix off-by-one error in validator Off-by-one error trying to get the element name when reaching an element with an invalid number of components. --- validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator.js b/validator.js index 72e16ba..4554bc2 100644 --- a/validator.js +++ b/validator.js @@ -149,7 +149,7 @@ Validator.prototype.onelement = function () { minimum = this._element.requires; maximum = this._element.components.length; if (this._counts.component < minimum || this._counts.component > maximum) { - name = this._segment.elements[this._counts.element]; + name = this._segment.elements[this._counts.element - 1]; throw Validator.errors.countError({ type: 'element', name: name,