- $validator = new JsonSchema\Validator();
- $validator->check( $data, $schema );
- if ( $validator->isValid() ) {
+ $licenseError = false;
+ // Check if it's a string, if not, schema validation will display an error
+ if ( isset( $data->{'license-name'} ) && is_string( $data->{'license-name'} ) ) {
+ $licenses = new SpdxLicenses();
+ $valid = $licenses->validate( $data->{'license-name'} );
+ if ( !$valid ) {
+ $licenseError = '[license-name] Invalid SPDX license identifier, '
+ . 'see <https://spdx.org/licenses/>';
+ }
+ }
+
+ $validator = new Validator;
+ $validator->check( $data, (object) [ '$ref' => 'file://' . $schemaPath ] );
+ if ( $validator->isValid() && !$licenseError ) {