Endpoint
POST /validate
Validates a SaaS pricing model provided as a YAML file and returns the configuration space of all valid subscription combinations. Implementation: Seeorg.isa.pricing.csp.controller.CSPController:33
The YAML file containing the pricing model in Pricing2YAML format. Must be uploaded as
multipart/form-data.Response
The endpoint returns aCSPOutput object with the validation results.
Indicates the outcome of the validation:
SUCCESS- The pricing model is valid and solvableVALIDATION_ERROR- Constraint violation found in the modelFILE_ERROR- File path invalid or file not foundYAML_ERROR- YAML syntax errorPARSER_ERROR- Error parsing the pricing model
The set of all valid subscription configurations. Only present when
messageType is SUCCESS.List of error messages. Present when
messageType is not SUCCESS. Each error describes a constraint violation or parsing issue.A string representation of the Choco constraint model (for debugging).
Debug information containing extracted features, plans, add-ons, and matrices from the pricing model.
Examples
Success Response
A valid pricing model returns all valid subscription configurations:Validation Error Response
An invalid model with constraint violations:File Error Response
Errors related to file upload or YAML parsing:How the Solver Works
The solver processes a pricing model through several stages:Stage 1: Parsing and Data Extraction
The YAML file is parsed using Pricing4Java into aPricingManager object (org.isa.pricing.csp.parser.Yaml2CSP:55):
Stage 2: Model Initialization
A ChocoModel is created with variables (org.isa.pricing.csp.service.CSPService:196):
selectedPlan: Integer variable representing the chosen plan (index)selectedAddOns: Binary array where1means the add-on is selectedsubscriptionCost: Total cost in cents
Stage 3: Data Integrity Validation
Before posting constraints, the service performs pure data validation (org.isa.pricing.csp.service.CSPService:224):
Plan Validation
- Each plan must have all features defined
- Each plan must have at least one feature enabled
- Plans must not be duplicates
Add-on Validation
- Each add-on must have correct feature/usage limit dimensions
- Availability, dependency, and exclusion matrices must be binary (0 or 1)
- Each add-on must be available for at least one plan
- Each add-on must provide at least one feature, usage limit, or extension
Feature Validation
- Features must be reachable (at least one plan or add-on enables them)
- Linked features must have corresponding positive usage limits
Stage 4: Constraint Posting
The service posts constraints to the Choco model (org.isa.pricing.csp.service.CSPService:650):
Existence Constraint
Availability Constraint
Dependency Constraint
Exclusion Constraint
Cost Constraint
Stage 5: Solving
The Choco solver finds all valid solutions (org.isa.pricing.csp.service.CSPService:944):
- Extracts the selected plan index
- Identifies which add-ons are selected (value = 1)
- Calculates the total cost
- Builds a
SubscriptionItemobject
Constraint Programming Concepts
The CSP Service models pricing validation as a Constraint Satisfaction Problem (CSP), which consists of:
- Variables with finite domains (e.g., selected plan ∈ )
- Constraints that restrict valid variable combinations
- A solution assigns values to all variables while satisfying all constraints
Key CSP Techniques Used
Constraint Propagation
Constraint Propagation
Choco uses propagation to reduce variable domains before search. When a constraint is posted, it removes values from variable domains that cannot participate in any valid solution.Example: If add-on A depends on add-on B, and B is not available for plan X, then propagation will set
selectedAddOns[A] = 0 when selectedPlan = X.Reification
Reification
Constraints can be reified into Boolean variables. This allows encoding “if-then” logic:Used extensively for add-on availability, dependencies, and exclusions.
Element Constraints
Element Constraints
Element constraints index into arrays using variables:Used to select the plan’s price based on the selected plan variable.
Global Constraints
Global Constraints
High-level constraints that encapsulate complex logic:
sum()- Sum of variables equals/greater than a valuescalar()- Weighted sum (used for cost calculation)or()- Disjunction of constraints (at least one must hold)
Explanation Engine
Explanation Engine
When a model is unsatisfiable, Choco’s explanation engine traces back through constraint propagations to identify the minimal set of constraints causing the conflict.This provides detailed error messages like:
Performance Optimization
The CSP Service includes several optimizations:Constant Variable Folding
Instead of creating decision variables for fixed values, the service creates constant variables:Early Failure Detection
The service performs data validation before constraint posting to fail fast on basic errors:Scaled Integer Encoding
Prices and usage limits are scaled to integers:- Prices: Converted to cents (multiply by 100)
- Usage limits: Scaled by 1000
Propagation Before Search
Integration with Analysis API
The Analysis API calls the CSP Service via HTTP:Analysis API → CSP Service
- Report model validity
- Count valid configurations (cardinality)
- Provide detailed error explanations
- Cache results for subsequent queries
Error Types Reference
FILE_ERROR
FILE_ERROR
Causes:
- File path does not exist
- File is not readable
- File is empty
YAML_ERROR
YAML_ERROR
Causes:
- Invalid YAML syntax
- Malformed structure
- Incorrect indentation
PARSER_ERROR
PARSER_ERROR
Causes:
- Invalid Pricing2YAML format
- Missing required fields
- Type mismatches
- References to non-existent features/limits
VALIDATION_ERROR
VALIDATION_ERROR
Causes:
- Constraint violations in the pricing model
- Logical inconsistencies
- Duplicate plans or add-ons
- Unreachable features or usage limits
- Invalid dependencies or exclusions
Testing the Endpoint
You can test the endpoint using sample YAML files from the project:Test with Slack 2024 pricing
Test with invalid model (duplicate plans)
Test with circular dependency
Related Documentation
CSP Overview
Learn about the CSP Service architecture and capabilities
Analysis API
See how the Analysis API uses the CSP Service
Pricing Models
Understand the YAML pricing model format
Choco Solver Docs
Official Choco Solver documentation