Skip to content
This repository was archived by the owner on May 7, 2018. It is now read-only.
This repository was archived by the owner on May 7, 2018. It is now read-only.

Cannot validate example document #45

@MitchK

Description

@MitchK

I took the example of https://www.imsglobal.org/sites/default/files/Badges/OBv2p0/index.html#intro-example and ran it through the validator.

I get this error

error:  { recipient:
   { Error: must be an email address or a self-identifying hash string (e.g., "sha256$abcdef123456789")
       at makeError (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:818:15)
       at required (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:994:63)
       at runTests (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:336:9)
       at taskValidateRecipient (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:320:16)
       at Array.async.auto.recipient (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:752:7)
       at /Users/user/repos/git/repo/node_modules/async/lib/async.js:459:38
       at Array.forEach (native)
       at _each (/Users/user/repos/git/repo/node_modules/async/lib/async.js:32:24)
       at Object.async.auto (/Users/user/repos/git/repo/node_modules/async/lib/async.js:430:9)
       at fullValidateBadgeAssertion (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:725:9)
     message: 'must be an email address or a self-identifying hash string (e.g., "sha256$abcdef123456789")',
     code: undefined } }
/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:985
      errors[(prefix.length ? (prefix + '.') : '') + field] = makeError(property, 'missing required value');
                                                     ^

ReferenceError: field is not defined
    at required (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:985:54)
    at runTests (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:336:9)
    at validateAssertionStructure (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:428:10)
    at taskValidateStructures (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:434:16)
    at Array.async.auto.objects (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:756:7)
    at /Users/user/repos/git/repo/node_modules/async/lib/async.js:459:38
    at Array.forEach (native)
    at _each (/Users/user/repos/git/repo/node_modules/async/lib/async.js:32:24)
    at Object.async.auto (/Users/user/repos/git/repo/node_modules/async/lib/async.js:430:9)
    at fullValidateBadgeAssertion (/Users/user/repos/git/repo/node_modules/openbadges-validator/index.js:725:9)

This is my code:

const obj = {
  "@context": "https://w3id.org/openbadges/v2",
  "id": "https://example.org/assertions/123",
  "type": "Assertion",
  "recipient": {
    "type": "email",
    "identity": "alice@example.org"
  },
  "issuedOn": "2016-12-31T23:59:59+00:00",
  "verification": {
    "type": "hosted"
  },
  "badge": {
    "type": "BadgeClass",
    "id": "https://example.org/badges/5",
    "name": "3-D Printmaster",
    "description": "This badge is awarded for passing the 3-D printing knowledge and safety test.",
    "image": "https://example.org/badges/5/image",
    "criteria": {
      "narrative": "Students are tested on knowledge and safety, both through a paper test and a supervised performance evaluation on live equipment"
    },
    "issuer": {
      "id": "https://example.org/issuer",
      "type": "Profile",
      "name": "Example Maker Society",
      "url": "https://example.org",
      "email": "contact@example.org",
      "verification": {
         "allowedOrigins": "example.org"
      }
    }
  }
}
const validator = require('openbadges-validator')
validator(obj, (err, data) => {
  console.log("error: ", err)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions