An open API service indexing awesome lists of open source software.

https://github.com/samply/common-mdrvalidator


https://github.com/samply/common-mdrvalidator

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# MDR Validation Project

## General information

This is a lib to validate value against the MDR.

## Usage

First prepare the MDR connection.
You need to provide:
* the URL to the MDR to be used
* the AUTH userId and keyId
* the AUTH URL to be used
* the privateKey used there (for signature)
* the MDR namespace
* the samply proxyConfiguration

MdrConnection mdrConnection = new MdrConnection(mdrUrl, authUserId, keyId, authUrl, privateKeyBase64, nameSpace, proxyConfiguration);

Then initiate the Validator and read out the members of the namespace

MDRValidator val = new MDRValidator(mdrConnection);
val.initMembers();

Now you can simply validate, by calling

val.validate(mdrKey, value)

Example:

String mdrKey = "urn:mdr:dataelement:1:1";

if(!val.validate(mdrKey, 900)) {
for(ErrorMessage error: val.getErrorMessage(mdrKey)) {
System.out.println(error.getDesignation()+ " : "+error.getDefinition());
}
}

assertFalse(val.validate(mdrKey, 900));
assertTrue(val.validate(mdrKey, 90));

As you can see you can get the error messages defined in MDR by calling

val.getErrorMessage(mdrKey)

## Build

Use maven to build the jar:

```
mvn clean install
```

## License

Copyright 2020 The Samply Development Community

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.