* Apply the invariant to a single pagination object. Returns the rule ID * when violated, or null. `cursor: null` is treated as present — the * spec's wire shape has the field absent on terminal pages, not present * with a null value. * * Asymmetry with `pagination-integrity.yaml`: the storyboa
(pagination)
| 116 | * tolerates — so don't "fix" one to match the other. |
| 117 | */ |
| 118 | function checkPagination(pagination) { |
| 119 | const hasCursor = Object.prototype.hasOwnProperty.call(pagination, 'cursor'); |
| 120 | if (pagination.has_more === true && !hasCursor) { |
| 121 | return { rule: 'has_more_true_missing_cursor' }; |
| 122 | } |
| 123 | if (pagination.has_more === false && hasCursor) { |
| 124 | return { rule: 'has_more_false_with_cursor' }; |
| 125 | } |
| 126 | return null; |
| 127 | } |
| 128 | |
| 129 | function lintSchemas(dir = SCHEMA_DIR) { |
| 130 | const violations = []; |
no outgoing calls
no test coverage detected