validateSchema() public method

Validates the schema from the json array and returns an error of syntax errors if any are found
See also: https://laravel.com/docs/5.2/migrations#creating-columns
See also: https://laravel.com/docs/5.2/migrations#creating-indexes
public validateSchema ( array $data ) : array
$data array The array containing the json output from file
return array Any errors identified for every field schema
 /**
  * Test validateSchema()
  *
  * @return void
  */
 public function testValidateSchema()
 {
     // Set the json array schema
     $schemaArray = ['dogs' => ['name' => 'string:unique', 'paws' => 'yesTheyHaveThemSometimes:index', 'canines' => 'boolean', 'hair' => 'string(50):index', 'ears_invalid' => 'string:thisIsMyInvalidModifier', 'ears_valid' => "string:after('id')"], 'create_cats_table' => ['hair' => 'boolean'], 'posts_tags_pivot' => null];
     // Validate schema
     $errors = $this->makeMigrationJson->validateSchema($schemaArray);
     // The 'paws' section should come back with invalid column type error
     $this->assertTrue(isset($errors['dogs']['paws']['columnType']), 'columnType: "paws" was supposed to come back with a column type error, instead we got: ' . json_encode($errors));
     // The 'ears_invalid' section should come back with invalid column type error
     $this->assertTrue(isset($errors['dogs']['ears_invalid']['columnModifier']), 'columnModifier: "ears_invalid" was supposed to come back with a column modifier error, instead we got: ' . json_encode($errors));
     // The 'hair' section should not come back with errors because of its optional column type parameters
     $this->assertFalse(isset($errors['dogs']['hair']), 'columnType: "hair:string(50):index" should be allowed to be validated as a "string", not as "string(50)": ');
     // The 'ears_valid' section should not come back with errors because it is a valid column modifier or index
     $this->assertFalse(isset($errors['dogs']['ears_valid']), 'columnType: "ears_valid" should not come back with errors because it is a valid column modifier or index');
 }
 /**
  * Validate the json file and console report any issues
  *
  * @return void
  */
 protected function validate()
 {
     // Get json array from file
     $jsonArray = $this->makeMigrationJson->jsonFileToArray($this->filePath);
     // Check for invalid json
     if ($jsonArray === null) {
         // Display error message
         $this->error('Invalid JSON detected: Check that your json file does not contain invalid syntax: ' . $this->filePath);
         // End further execution
         return;
     }
     // Check for data existence
     if (empty($jsonArray)) {
         // Display error message
         $this->error('No data found in json file: It seems you have no data in: ' . $this->filePath);
         // End further execution
         return;
     }
     // Validate
     $errors = $this->makeMigrationJson->validateSchema($jsonArray);
     // If no errors where found
     if (empty($errors)) {
         // Display confirmation message
         $this->info('No validation errors where found, congrats!');
         // End further execution
         return;
     }
     // Report results
     foreach ($errors as $tableName => $fields) {
         // For every field
         foreach ($fields as $fieldName => $fieldProperties) {
             // For every field property
             foreach ($fieldProperties as $property) {
                 // Show error
                 $this->error($property);
                 // Show json reference
                 $this->error("In section: " . json_encode([$tableName => [$fieldName => $jsonArray[$tableName][$fieldName]]], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
             }
         }
     }
 }