Skip to content

Commit 72e0031

Browse files
committed
Merges master.
2 parents 8b4003c + efe3030 commit 72e0031

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/StatementBase.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php namespace Locker\XApi;
2+
use Locker\XApi\Errors\Error as Error;
23

34
class StatementBase extends Element {
45
protected $props = [
@@ -11,4 +12,20 @@ class StatementBase extends Element {
1112
'attachments' => 'Locker\XApi\Attachments'
1213
];
1314
protected $required_props = ['actor', 'verb', 'object'];
15+
16+
public function validate() {
17+
$errors = [];
18+
$verb_id = $this->getPropValue('verb.id');
19+
$object_type = $this->getPropValue('object.objectType');
20+
21+
// Validates voider.
22+
if (
23+
$verb_id === 'http://adlnet.gov/expapi/verbs/voided' &&
24+
$object_type !== 'StatementRef'
25+
) {
26+
$errors[] = new Error("`object.objectType` must be `StatementRef` not `$object_type` when voiding");
27+
}
28+
29+
return array_merge($errors, parent::validate());
30+
}
1431
}

tests/test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use Locker\XApi as XApi;
55

6-
6+
header('Content-Type: application/json');
77
try {
88
// Code.
99
$file_location = 'assets/test.json';

0 commit comments

Comments
 (0)