@zeropress/preview-data-validator 0.2.0 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeropress/preview-data-validator",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shared ZeroPress preview data validation core",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -43,7 +43,7 @@ function validateSite(site, path, errors) {
43
43
 
44
44
  validateNonEmptyString(site.title, `${path}.title`, 'INVALID_SITE_TITLE', errors);
45
45
  validateString(site.description, `${path}.description`, 'INVALID_SITE_DESCRIPTION', errors);
46
- validateUri(site.url, `${path}.url`, 'INVALID_SITE_URL', errors);
46
+ validateSiteUri(site.url, `${path}.url`, 'INVALID_SITE_URL', errors);
47
47
  validateNonEmptyString(site.language, `${path}.language`, 'INVALID_SITE_LANGUAGE', errors);
48
48
 
49
49
  if (site.logo !== undefined) {
@@ -351,6 +351,14 @@ function validateUri(value, path, code, errors) {
351
351
  }
352
352
  }
353
353
 
354
+ function validateSiteUri(value, path, code, errors) {
355
+ if (value === '') {
356
+ return;
357
+ }
358
+
359
+ validateUri(value, path, code, errors);
360
+ }
361
+
354
362
  function issue(code, path, message) {
355
363
  return {
356
364
  code,
@@ -34,7 +34,13 @@
34
34
  "properties": {
35
35
  "title": { "type": "string", "minLength": 1 },
36
36
  "description": { "type": "string" },
37
- "url": { "type": "string", "format": "uri" },
37
+ "url": {
38
+ "type": "string",
39
+ "anyOf": [
40
+ { "const": "" },
41
+ { "format": "uri" }
42
+ ]
43
+ },
38
44
  "language": { "type": "string", "minLength": 2 },
39
45
  "logo": { "type": "string", "format": "uri" },
40
46
  "social": {