zenn-model 0.2.1 → 0.2.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -52,6 +52,7 @@ const validateArticle = (article) => {
52
52
  import_utils.validateMissingEmoji,
53
53
  import_utils.validateMissingTopics,
54
54
  import_utils.validateUseTags,
55
+ import_utils.validateTopicLength,
55
56
  import_utils.validateInvalidTopicLetters,
56
57
  import_utils.validateTooManyTopics,
57
58
  import_utils.validateTopicType,
@@ -68,6 +69,7 @@ const validateBook = (book) => {
68
69
  import_utils.validatePublishedStatus,
69
70
  import_utils.validateMissingTopics,
70
71
  import_utils.validateUseTags,
72
+ import_utils.validateTopicLength,
71
73
  import_utils.validateInvalidTopicLetters,
72
74
  import_utils.validateTooManyTopics,
73
75
  import_utils.validateTopicType,
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type Dect = Record<string, any>;
2
- export type ValidationErrorType = 'body' | 'item-slug' | 'missing-title' | 'title-length' | 'published-status' | 'published-at-parse' | 'published-at-schedule' | 'article-type' | 'missing-emoji' | 'emoji-format' | 'missing-topics' | 'too-many-topics' | 'topic-type' | 'invalid-topic-letters' | 'use-tags' | 'publication-name' | 'book-summary' | 'book-price-type' | 'book-price-range' | 'book-price-fraction' | 'missing-book-cover' | 'book-cover-size' | 'book-cover-aspect-ratio' | 'book-chapter-slugs' | 'book-chapters-format' | 'chapter-item-slug' | 'chapter-free-type';
2
+ export type ValidationErrorType = 'body' | 'item-slug' | 'missing-title' | 'title-length' | 'published-status' | 'published-at-parse' | 'published-at-schedule' | 'article-type' | 'missing-emoji' | 'emoji-format' | 'missing-topics' | 'too-many-topics' | 'topic-type' | 'topic-length' | 'invalid-topic-letters' | 'use-tags' | 'publication-name' | 'book-summary' | 'book-price-type' | 'book-price-range' | 'book-price-fraction' | 'missing-book-cover' | 'book-cover-size' | 'book-cover-aspect-ratio' | 'book-chapter-slugs' | 'book-chapters-format' | 'chapter-item-slug' | 'chapter-free-type';
3
3
  export type ItemValidator = {
4
4
  type: ValidationErrorType;
5
5
  isCritical?: boolean;
package/lib/utils.d.ts CHANGED
@@ -16,6 +16,7 @@ export declare const validateEmojiFormat: ItemValidator;
16
16
  export declare const validateMissingTopics: ItemValidator;
17
17
  export declare const validateTooManyTopics: ItemValidator;
18
18
  export declare const validateTopicType: ItemValidator;
19
+ export declare const validateTopicLength: ItemValidator;
19
20
  export declare const validateInvalidTopicLetters: ItemValidator;
20
21
  export declare const validateUseTags: ItemValidator;
21
22
  export declare const validatePublicationName: ItemValidator;
package/lib/utils.js CHANGED
@@ -57,6 +57,7 @@ __export(utils_exports, {
57
57
  validateSlug: () => validateSlug,
58
58
  validateTitleLength: () => validateTitleLength,
59
59
  validateTooManyTopics: () => validateTooManyTopics,
60
+ validateTopicLength: () => validateTopicLength,
60
61
  validateTopicType: () => validateTopicType,
61
62
  validateUseTags: () => validateUseTags
62
63
  });
@@ -198,6 +199,18 @@ const validateTopicType = {
198
199
  return topics.every((t) => typeof t === "string" && t.length > 0);
199
200
  }
200
201
  };
202
+ const validateTopicLength = {
203
+ type: "topic-length",
204
+ isCritical: true,
205
+ getMessage: () => "topics\u306F18\u5B57\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044",
206
+ isValid: ({ topics }) => {
207
+ if (!Array.isArray(topics))
208
+ return true;
209
+ if (topics.some((t) => typeof t !== "string"))
210
+ return true;
211
+ return topics.every((t) => typeof t === "string" && t.length <= 18);
212
+ }
213
+ };
201
214
  const validateInvalidTopicLetters = {
202
215
  type: "invalid-topic-letters",
203
216
  getMessage: () => "topics\u306B\u8A18\u53F7\u3084\u30B9\u30DA\u30FC\u30B9\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002\u4F8B\u3048\u3070C++\u306F\u300Ccpp\u300D\u3001C#\u306F\u300Ccsharp\u300D\u3068\u8A18\u8F09\u3057\u3066\u304F\u3060\u3055\u3044",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zenn-model",
3
- "version": "0.2.1",
3
+ "version": "0.2.2-alpha.1",
4
4
  "license": "MIT",
5
5
  "description": "Model utils for Zenn contents",
6
6
  "main": "lib/index.js",
@@ -42,5 +42,5 @@
42
42
  "cheerio": "^1.0.0-rc.12",
43
43
  "emoji-regex": "^10.2.1"
44
44
  },
45
- "gitHead": "fbb607e5a9dc06f499d58fae00c60f7f66a71b7d"
45
+ "gitHead": "0fe217aeb6d8328fb785e6972c27dbed1e6534f9"
46
46
  }