@prezly/content-format
Advanced tools
Comparing version 0.59.0 to 0.60.0
import { Element } from '../Element'; | ||
import { isObject, isUuid } from '../validation'; | ||
import { isBoolean, isEnum, isObject, isUuid } from '../validation'; | ||
export var ContactNode; | ||
(function (ContactNode) { | ||
ContactNode.TYPE = 'contact'; | ||
let Layout; | ||
(function (Layout) { | ||
Layout["CARD"] = "card"; | ||
Layout["SIGNATURE"] = "signature"; | ||
})(Layout = ContactNode.Layout || (ContactNode.Layout = {})); | ||
function isContactNode(value) { | ||
@@ -11,3 +16,7 @@ return Element.isElement(value, ContactNode.TYPE); | ||
function validateContactNode(value) { | ||
const isValid = isContactNode(value) && isUuid(value.uuid) && isObject(value.contact); | ||
const isValid = isContactNode(value) && | ||
isUuid(value.uuid) && | ||
isObject(value.contact) && | ||
isEnum(value.layout, ContactNode.Layout) && | ||
isBoolean(value.show_avatar); | ||
return isValid ? value : null; | ||
@@ -14,0 +23,0 @@ } |
@@ -9,2 +9,4 @@ import { Element } from '../Element'; | ||
contact: ContactNode.ContactInfo; | ||
layout: `${ContactNode.Layout}`; | ||
show_avatar: boolean; | ||
} | ||
@@ -26,2 +28,6 @@ export declare namespace ContactNode { | ||
} | ||
enum Layout { | ||
CARD = "card", | ||
SIGNATURE = "signature" | ||
} | ||
function isContactNode(value: any): value is ContactNode; | ||
@@ -28,0 +34,0 @@ function validateContactNode(value: any): ContactNode | null; |
{ | ||
"name": "@prezly/content-format", | ||
"version": "0.59.0", | ||
"version": "0.60.0", | ||
"description": "Prezly Content Format types and utilities", | ||
@@ -53,3 +53,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "4825f366b51fbafbbdfcee8ea6d26d32e59238ed" | ||
"gitHead": "b5d7537c9ea4c6a7da1a5babb668132312d069a0" | ||
} |
import { Element } from '../Element'; | ||
import { isObject, isUuid } from '../validation'; | ||
import { isBoolean, isEnum, isObject, isUuid } from '../validation'; | ||
@@ -12,2 +12,4 @@ interface NewsroomContact { | ||
contact: ContactNode.ContactInfo; | ||
layout: `${ContactNode.Layout}`; | ||
show_avatar: boolean; | ||
} | ||
@@ -32,2 +34,7 @@ | ||
export enum Layout { | ||
CARD = 'card', | ||
SIGNATURE = 'signature', | ||
} | ||
export function isContactNode(value: any): value is ContactNode { | ||
@@ -38,3 +45,8 @@ return Element.isElement(value, TYPE); | ||
export function validateContactNode(value: any): ContactNode | null { | ||
const isValid = isContactNode(value) && isUuid(value.uuid) && isObject(value.contact); | ||
const isValid = | ||
isContactNode(value) && | ||
isUuid(value.uuid) && | ||
isObject(value.contact) && | ||
isEnum(value.layout, ContactNode.Layout) && | ||
isBoolean(value.show_avatar); | ||
@@ -41,0 +53,0 @@ return isValid ? value : null; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
204165
218
4017
1