This function uses the rulr.isScormInteractionType
guard to check the input is a valid SCORM interaction type as shown in the example below. It should only throw rulr.InvalidScormInteractionTypeError
. This is a little convenience rule for everyone trying to improve the world's training using SCORM or the xAPI, this package might not exist without these people.
import * as rulr from 'rulr'
const constrainToExample = rulr.object({
required: {
example: rulr.scormInteractionType,
},
})
type Example = rulr.Static<typeof constrainToExample>
// {
// example: rulr.ScormInteractionType
// }
// Valid
const example1: Example = constrainToExample({
example: 'choice', // rulr.ScormInteractionType.Choice
})
// Invalid: Not a valid SCORM interaction type
const example2: Example = constrainToExample({
example: 'choices',
})
// Invalid: Not a string
const example3: Example = constrainToExample({
example: 1,
})