code: def validate(self, **kwargs):
          
  
          default_data_schema = json.load(open(self.default_schema_file, 'r'))
  
          # even though we are using the yaml package to load,
          # it supports JSON and YAML
          data = kwargs.pop("data", None)
          file_path = kwargs.pop("file_path", None)
  
          if file_path is None:
              raise LookupError("file_path argument must be supplied")
  
          if data is None:
  
              try:
                  data = yaml.load(open(file_path, 'r'), Loader=Loader)
              except Exception as e:
                  self.add_validation_message(ValidationMessage(file=file_path, message=
                  'There was a problem parsing the file.\n' + e.__str__()))
                  return False
  
          try:
  
              if 'type' in data:
                  custom_schema = self.load_custom_schema(data['type'])
                  json_validate(data, custom_schema)
              else:
                  json_validate(data, default_data_schema)
  
          except ValidationError as ve:
  
              self.add_validation_message(
                  ValidationMessage(file=file_path,
                                      message=ve.message + ' in ' + str(ve.instance)))
  
          if self.has_errors(file_path):
              return False
          else:
              return True
docs: Validates a data file
  
          :param file_path: path to file to be loaded.
          :param data: pre loaded YAML object (optional).
          :return: Bool to indicate the validity of the file.