Skip to content

Commit

Permalink
fix(PostalAddress): Add schema: prefix; add checks for this
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Mar 6, 2020
1 parent 9a01142 commit 0291760
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions schema/PostalAddress.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ category: metadata
description: A physical mailing address.
properties:
streetAddress:
'@id': streetAddress
'@id': schema:streetAddress
description: The street address.
$comment: For example, 10 Downing Street.
type: string
postOfficeBoxNumber:
'@id': postOfficeBoxNumber
'@id': schema:postOfficeBoxNumber
description: The post office box number.
type: string
addressLocality:
'@id': addressLocality
'@id': schema:addressLocality
description: The locality in which the street address is, and which is in the region.
$comment: For example, London.
type: string
addressRegion:
'@id': addressRegion
'@id': schema:addressRegion
description: The region in which the locality is, and which is in the country.
$comment: For example, California or another appropriate first-level Administrative division
type: string
postalCode:
'@id': postalCode
'@id': schema:postalCode
description: The postal code.
$comment: For example, 94043.
type: string
Expand Down
4 changes: 4 additions & 0 deletions ts/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ const checkSchema = (
const id = schema['@id']
if (id === undefined) error(`${title} is missing @id`)
else {
if (!/^[a-z]+:/.test(id))
error(`@id "${id}" is not prefixed witha vocabulary e.g. "schema:"`)
if (allIds[id] !== undefined && allIds[id] !== title)
error(
`@id "${id}" is associated with more than one name "${allIds[id]}", "${title}"`
Expand All @@ -196,6 +198,8 @@ const checkSchema = (
const id = property['@id']
if (id === undefined) error(`${title}.${name} is missing @id`)
else {
if (!/^[a-z]+:/.test(id))
error(`@id "${id}" is not prefixed witha vocabulary e.g. "schema:"`)
if (allIds[id] !== undefined && allIds[id] !== name)
error(
`@id "${id}" is associated with more than one name "${allIds[id]}", "${name}"`
Expand Down

0 comments on commit 0291760

Please sign in to comment.