public static function validate($source, $basePath = null)
    {
        $curResource = 1;
        $curLine = null;
        try {
            $datapackage = static::datapackage($source, $basePath);
            foreach ($datapackage as $resource) {
                $curLine = 1;
                foreach ($resource as $line) {
                    if ($curLine == self::VALIDATE_PEEK_LINES) {
                        break;
                    }
                    ++$curLine;
                }
                ++$curResource;
            }
            // no validation errors
            return [];
        } catch (Exceptions\DatapackageInvalidSourceException $e) {
            // failed to load the datapackage descriptor
            // return a list containing a single LOAD_FAILED validation error
            return [
                new Validators\DatapackageValidationError(
                    Validators\DatapackageValidationError::LOAD_FAILED, $e->getMessage()
                ),
            ];
        } catch (Exceptions\DatapackageValidationFailedException $e) {
            // datapackage descriptor failed validation - return the validation errors
            return $e->validationErrors;
        } catch (Exceptions\ResourceValidationFailedException $e) {
            // resource descriptor failed validation - return the validation errors
            return [
                new Validators\DatapackageValidationError(
                    Validators\DatapackageValidationError::RESOURCE_FAILED_VALIDATION,
                    [
                        'resource' => $curResource,
                        'validationErrors' => $e->validationErrors,
                    ]
                ),
            ];
        } catch (Exceptions\DataStreamOpenException $e) {
            // failed to open data stream
            return [
                new Validators\DatapackageValidationError(
                    Validators\DatapackageValidationError::DATA_STREAM_FAILURE,
                    [
                        'resource' => $curResource,
                        'line' => 0,
                        'error' => $e->getMessage(),
                    ]
                ),
            ];
        } catch (Exceptions\DataStreamValidationException $e) {
            // failed to validate the data stream
            return [
                new Validators\DatapackageValidationError(
                    Validators\DatapackageValidationError::DATA_STREAM_FAILURE,
                    [
                        'resource' => $curResource,
                        'line' => $curLine,
                        'error' => $e->getMessage(),
                    ]
                ),
            ];
        }
    }