MCPcopy
hub / github.com/ampproject/amphtml / shouldUse

Function shouldUse

build-system/compile/json-schema/index.js:41–55  ·  view source on GitHub ↗
(schema)

Source from the content-addressed store, hash-verified

39 fn: 'isIso4217CurrencyCode',
40 error: {message: 'must be a valid ISO 4217 currency code'},
41 shouldUse(schema) {
42 if (!iso4217DescriptionRe.test(schema.description)) {
43 return false;
44 }
45 if (
46 !Array.isArray(schema.enum) ||
47 JSON.stringify(schema.enum.sort()) !== JSON.stringify(iso4217.sort())
48 ) {
49 throw new Error(
50 'ISO 4217 schema must contain an `enum` keyword including all valid currency codes.'
51 );
52 }
53 delete schema.enum;
54 return true;
55 },
56 },
57];
58

Callers 1

Calls 2

stringifyMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected