Skip to content

Commit 31b85a1

Browse files
committed
fix: iso8601 rule paths to be more exact
1 parent 6ca7dfc commit 31b85a1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

isp-functions/iso8601.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const DATELIKE = /created|started|executed|modified|canceled|stopped|deleted|dat
22

33
// ISO8601 ensures parameters that look like they might hold dates are formatted
44
// correctly according to ISO 8601 (e.g. `2020-01-01T12:00:00Z`)
5-
module.exports = targetValue => {
5+
module.exports = (targetValue, options, paths) => {
66
const errors = [];
77

88
// No parameter should end with a time zone in the name.
@@ -35,9 +35,11 @@ module.exports = targetValue => {
3535
message: `${targetValue.name} should have a schema`
3636
});
3737
} else {
38+
let p = paths.given.concat(['schema']);
3839
if (targetValue.schema.type && targetValue.schema.type !== 'string') {
3940
errors.push({
40-
message: `${targetValue.name} should be a string if it is a date/time`
41+
message: `${targetValue.name} should be a string if it is a date/time`,
42+
path: targetValue.schema.type ? p.concat(['type']) : p
4143
});
4244
}
4345

@@ -46,7 +48,8 @@ module.exports = targetValue => {
4648
targetValue.schema.format != 'date-time'
4749
) {
4850
errors.push({
49-
message: `${targetValue.name} should have a string format of 'date' or 'date-time'`
51+
message: `${targetValue.name} should have a string format of 'date' or 'date-time'`,
52+
path: p
5053
});
5154
}
5255
}

0 commit comments

Comments
 (0)