Skip to content

Commit

Permalink
Validation is assumed.
Browse files Browse the repository at this point in the history
  • Loading branch information
svandragt committed Oct 1, 2020
1 parent 090f4d3 commit 9f1f51d
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Model
{
public $contents = [];
public $model = [];
public $required_fields = [];

public function __construct($records)
{
Expand Down Expand Up @@ -78,8 +77,6 @@ protected function listContents($record): StdClass
$Content->$section_value = $this->section($content_section, $section_key);
}

$this->validate($Content);

return $Content;
}

Expand Down Expand Up @@ -115,19 +112,4 @@ public function section(string $content_section, $section_key): StdClass

return $Section;
}


public function validate($Content)
{
foreach ($this->required_fields as $section => $fields) {
if (!property_exists($Content, $section)) {
throw new Exception("Required section '$section' missing in content.");
}
foreach ($fields as $field) {
if (!property_exists($Content->$section, $field)) {
throw new Exception("Required $section field '$field' missing in content.");
}
}
}
}
}

0 comments on commit 9f1f51d

Please sign in to comment.