Skip to content

Commit

Permalink
chore: use optional chaining
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Hudlow <[email protected]>
  • Loading branch information
dpopp07 and hudlow authored Jan 8, 2025
1 parent 9b07fb6 commit dd0469b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ruleset/src/functions/use-date-based-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function performValidation(schema, path, exampleValue) {
// parses the object, looking for the value at that path. If it finds one,
// the value will be returned. If not, the function will return `undefined`.
function getObjectValueAtPath(obj, pathToValue) {
return pathToValue.reduce((value, field) => value[field], obj);
return pathToValue.reduce((value, field) => value?.[field], obj);
}

// "Indirect" examples are those coming from request bodies, response bodies, and parameters.
Expand Down

0 comments on commit dd0469b

Please sign in to comment.