mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 20:13:07 +00:00
added doc
This commit is contained in:
@@ -1,12 +1,20 @@
|
|||||||
import * as schema from './dspace-rest-v2.schema.json'
|
import * as schema from './dspace-rest-v2.schema.json'
|
||||||
import { Validator } from "jsonschema";
|
import { Validator } from "jsonschema";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies a document is a valid response from
|
||||||
|
* a DSpace REST API v2
|
||||||
|
*/
|
||||||
export class DSpaceRESTv2Validator {
|
export class DSpaceRESTv2Validator {
|
||||||
|
|
||||||
constructor(private document: any) {
|
constructor(private document: any) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an exception if this.document isn't a valid response from
|
||||||
|
* a DSpace REST API v2. Succeeds otherwise.
|
||||||
|
*/
|
||||||
validate(): void {
|
validate(): void {
|
||||||
const validator = new Validator();
|
const validator = new Validator();
|
||||||
const result = validator.validate(this.document, schema);
|
const result = validator.validate(this.document, schema);
|
||||||
|
Reference in New Issue
Block a user