Skip to content

Commit

Permalink
♽ Refactor error suppression (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Nov 30, 2023
1 parent 4846c7f commit d83e4b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-eggs-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-frontmatter': patch
---

Simplify error message suppression in numbering
12 changes: 4 additions & 8 deletions packages/myst-frontmatter/src/numbering/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {
defined,
incrementOptions,
validateBoolean,
validateKeys,
validateObject,
validateObjectKeys,
validateString,
} from 'simple-validators';
import type { Numbering } from './types.js';
Expand Down Expand Up @@ -34,13 +33,10 @@ export const NUMBERING_ALIAS = {
* Validate Numbering object
*/
export function validateNumbering(input: any, opts: ValidationOptions): Numbering | undefined {
const obj = validateObject(input, opts);
if (obj === undefined) return undefined;
const value = validateKeys(
obj,
const value = validateObjectKeys(
input,
{ optional: [...NUMBERING_KEYS, ...NUMBERING_OPTIONS], alias: NUMBERING_ALIAS },
// Do not add warnings on this filter process
{ property: '', messages: { errors: [], warnings: [] }, keepExtraKeys: true },
{ ...opts, suppressWarnings: true, keepExtraKeys: true },
);
if (value === undefined) return undefined;
const output: Record<string, any> = {};
Expand Down

0 comments on commit d83e4b6

Please sign in to comment.