anskaffelser / vefa-validator

Generic validator as a Java library originally created for use within eProcurement.
17 stars 17 forks source link

Maven Central Docker

VEFA Validator 2.x

This repository contains the code of the validation library for Java of which may be used to validate document related to eProcurement. The library is intended to be included in your software where you need support for document validation, it is not prossible to perform validation by simply compiling the project.

This library does not contain validation rules for any of the eProcurement documents supported. If you have issues related to specific types of documents, please make sure to create whose issues in the respective repository, e.g. ehf-postaward-g3 for Post-Award documents or eforms-sdk-nor for eForms.

Features

Getting started

Include dependency in your pom.xml:

<dependency>
  <groupId>no.difi.vefa</groupId>
  <artifactId>validator-core</artifactId>
  <version>2.1.0</version>
</dependency>

Start validating business documents:

// Create a new validator using validation artifacts from DFØ.
Validator validator = ValidatorBuilder.newValidator().build();

// Validate business document.
Validation validation = validator.validate(Paths.get("/path/to/document.xml"));

// Print result of validation.
System.out.println(validation.getReport().getFlag());

The validator is expensive to create, one instance should be enough.

New repositories

Repositories referenced in the code was moved as of September 1st 2020. To switch to the new repository, adding source in the ValidatorBuilder is required. Example of how it may look like:

Validator validator = ValidatorBuilder.newValidator()
    .setSource(RepositorySource.of("https://anskaffelser.dev/repo/validator/current/"))
    .build();

More information on the change and link to the new test repository may be found in the announcment of the new repositories.