Validation Provider

Estimated reading: 2 minutes 5 views

Overview

The Validation Provider is a Wattyo component that is responsible for validating the Billable Elements before executing the billing processes.

Wattyo comes with out-of-the-box validation rules, but you can extend them by creating your own provider.

Out-of-the-box Validation Rules

The out-of-the-box Validations are split into two categories:

  • Date Validations: They check that the required dates are present and that they have valid values to process the invoice.
  • Usage Validations: They check that the required usage data is present and that it has valid values to process the invoice.

Custom Validation Provider

In case you need to implement custom validation you can do it by creating your own validation provider.

Validation Provider Interface

The ValidationProvider interface is defined as follows:

interface BillingValidationInterface {
    void init(Map<Id, CalculationContext> calculationContextsMaps,  Map<String, Object> commonContext);
    boolean isEarlyValidation();
    boolean meetsEntryCriteria(CalculationContext cc, Map<String, Object> commonContext);
    List<Message> validate(CalculationContext cc, Map<String, Object> commonContext);
}

init

Initializes the provider passing Calculation Contexts and the Common Context. This method is called before the validation process and have access to the whole set of data that is going to be validated.

isEarlyValidation

Returns true if it’s an early validation. Otherwise, it returns false.

There are two stages of validations, the early validation and the late validation. The early validation is executed when the Calculation Context only has loaded the Billable Element. The late validation is executed after the whole Calculation Context has been loaded: Usages, Tehcnical Characteristicts, etc.

meetsEntryCriteria

Returns true if the Calculation Context meets the entry criteria. Otherwise, it returns false.

validate

Validates the Calculation Context and returns a list of messages with the validation results.

Message DTO

The Message is the object that the provider must return. It is defined as follows:

class Message {

    enum MessageType {INFO, WARN, ERROR, DEBUG, DISCARD, NONE}

    String title;
    String message;
    MessageType type;
    Object item;
}

Leave a Comment

       
Euphoria, forever till the end of times

Euphoria

Share this Doc

Validation Provider

Or copy link

CONTENTS