Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v17'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsup committed Apr 25, 2023
2 parents c1c605a + c19ae3d commit 7ead57a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ module.exports = internals.State = class {

this.mainstay.restore();
}

commit() {

if (this.mainstay.shadow) {
this.mainstay.shadow.override(this.path, this._snapshot);
this._snapshot = undefined;
}

this.mainstay.commit();
}
};


Expand Down
2 changes: 2 additions & 0 deletions lib/types/alternatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = Any.extend({
const result = item.schema.$_validate(value, localState, prefs);
if (!result.errors) {
matched.push(result.value);
localState.commit();
}
else {
failed.push(result.errors);
Expand Down Expand Up @@ -112,6 +113,7 @@ module.exports = Any.extend({

const result = item.schema.$_validate(value, localState, prefs);
if (!result.errors) {
localState.commit();
return result;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/types/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ module.exports = Any.extend({
requiredChecks[j] = res;

if (!res.errors) {
localState.commit();
value[i] = res.value;
isValid = true;
internals.fastSplice(requireds, j);
Expand Down Expand Up @@ -270,6 +271,7 @@ module.exports = Any.extend({

res = inclusion.$_validate(item, localState, prefs);
if (!res.errors) {
localState.commit();
if (inclusion._flags.result === 'strip') {
internals.fastSplice(value, i);
--i;
Expand Down
5 changes: 5 additions & 0 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ internals.Mainstay = class {
this.externals = snapshot.externals;
this.warnings = snapshot.warnings;
}

commit() {

this._snapshots.pop();
}
};


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "joi",
"description": "Object schema validation",
"version": "17.9.1",
"version": "17.9.2",
"repository": "git://github.com/hapijs/joi",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down

0 comments on commit 7ead57a

Please sign in to comment.