You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by "Serge Huber (Jira)" <ji...@apache.org> on 2025/02/16 18:25:00 UTC
[jira] [Assigned] (UNOMI-883) Implement Unified Condition Validation Service for Enhanced Developer Experience and Error Prevention
[ https://issues.apache.org/jira/browse/UNOMI-883?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Serge Huber reassigned UNOMI-883:
---------------------------------
Assignee: Serge Huber
> Implement Unified Condition Validation Service for Enhanced Developer Experience and Error Prevention
> -----------------------------------------------------------------------------------------------------
>
> Key: UNOMI-883
> URL: https://issues.apache.org/jira/browse/UNOMI-883
> Project: Apache Unomi
> Issue Type: Sub-task
> Components: unomi(-core)
> Affects Versions: unomi-3.0.0
> Reporter: Serge Huber
> Assignee: Serge Huber
> Priority: Major
> Fix For: unomi-3.0.0
>
>
> h2. Description
> This ticket is about implementing a unified approach to validate conditions across different services to prevent invalid conditions from being stored and ensure developer experience. We have always provided type for the values, so these can also be used to validate the condition parameter values, but the idea is to go further to add an optional validation sub-object to specify additional validation requirements. The aim is to, for example, make sure developers don't forget parameters such as "operator" for the "booleanCondition", which could lead to difficult to understand errors.
> h3. Implementation Details
> h4. Core Features
> The new ConditionValidation class provides the following validation capabilities:
> *Parameter Types Support:*
> * STRING
> * INTEGER
> * LONG
> * FLOAT
> * DOUBLE
> * BOOLEAN
> * DATE
> * CONDITION
> * OBJECT
> *Validation Features:*
> # Required Parameters
> ** Ability to mark parameters as mandatory
> # Allowed Values
> ** Define a set of valid values for a parameter
> # Condition Tags
> ** Specify allowed condition tags
> ** Filter conditions based on tags
> # Condition Type Restrictions
> ** Define disallowed condition types
> # Exclusive Parameters
> ** Support for mutually exclusive parameters
> ** Group exclusive parameters together
> # Recommended Parameters
> ** Mark parameters as recommended but not required
> # Custom Type Support
> ** Specify custom Java types for OBJECT parameters
> h3. Example Condition Type Definition
> {code:json}
> {
> "metadata": {
> "id": "propertyCondition",
> "name": "Property Condition",
> "description": "Compares a property value"
> },
> "parameters": [
> {
> "name": "propertyName",
> "type": "string",
> "validation": {
> "required": true
> }
> },
> {
> "name": "comparisonOperator",
> "type": "string",
> "validation": {
> "required": true,
> "allowedValues": ["equals", "notEquals", "greaterThan", "lessThan", "exists", "missing"]
> }
> },
> {
> "name": "propertyValue",
> "type": "string",
> "validation": {
> "recommended": true,
> "exclusive": true,
> "exclusiveGroup": "valueGroup"
> }
> }
> ]
> }
> {code}
> h3. Service Integration
> The validation service has been integrated with:
> * SegmentService
> * RulesService
> * GoalsService
> h3. Benefits
> * Centralized validation logic
> * Consistent validation across services
> * Clear distinction between required and recommended parameters
> * Support for complex parameter relationships
> * Type safety through custom type validation
> h2. Related Documentation
> * API Documentation: ConditionValidation class
> * Integration Examples: See SegmentServiceImpl, RulesServiceImpl, and GoalsServiceImpl
> * Test Cases: Validation scenarios in respective service tests
> h2. Detailed Condition Type Examples
> h3. Boolean Condition Type
> {code:json}
> {
> "metadata": {
> "id": "booleanCondition",
> "name": "Boolean Condition",
> "description": "Combines multiple conditions with a logical operator"
> },
> "parameters": [
> {
> "id": "operator",
> "type": "string",
> "validation": {
> "required": true,
> "allowedValues": ["and", "or"]
> }
> },
> {
> "id": "subConditions",
> "type": "condition",
> "multivalued": true,
> "validation": {
> "required": true
> }
> }
> ]
> }
> {code}
> h3. Profile Property Condition Type
> {code:json}
> {
> "metadata": {
> "id": "profilePropertyCondition",
> "name": "Profile Property Condition",
> "description": "Evaluates a profile property against various comparison criteria"
> },
> "parameters": [
> {
> "id": "propertyName",
> "type": "string",
> "validation": {
> "required": true
> }
> },
> {
> "id": "comparisonOperator",
> "type": "string",
> "validation": {
> "required": true,
> "allowedValues": [
> "equals",
> "notEquals",
> "lessThan",
> "greaterThan",
> "lessThanOrEqualTo",
> "greaterThanOrEqualTo",
> "between",
> "exists",
> "missing",
> "contains",
> "notContains",
> "startsWith",
> "endsWith",
> "matchesRegex"
> ]
> }
> },
> {
> "id": "propertyValue",
> "type": "string",
> "validation": {
> "recommended": true,
> "exclusive": true,
> "exclusiveGroup": "valueGroup"
> }
> },
> {
> "id": "propertyValueInteger",
> "type": "integer",
> "validation": {
> "recommended": true,
> "exclusive": true,
> "exclusiveGroup": "valueGroup"
> }
> },
> {
> "id": "propertyValueDate",
> "type": "date",
> "validation": {
> "recommended": true,
> "exclusive": true,
> "exclusiveGroup": "valueGroup"
> }
> }
> ]
> }
> {code}
> The actual implemented validation features include:
> 1. Basic Parameter Validation:
> * Required parameters
> * Recommended parameters
> * Parameter type validation (STRING, INTEGER, LONG, FLOAT, DOUBLE, BOOLEAN, DATE, CONDITION, OBJECT)
> 2. Value Constraints:
> * Allowed values (enumeration)
> * Custom type validation for OBJECT type
> 3. Condition-Specific Validation:
> * Allowed condition tags
> * Disallowed condition types
> * Nested condition validation
> 4. Parameter Relationships:
> * Exclusive parameters
> * Exclusive parameter groups
> 5. Collection Support:
> * Multivalued parameter validation
> * Collection type validation
> * Empty collection validation for required parameters
> The implementation does not include some of the features I incorrectly included in my previous examples:
> * Pattern matching for strings
> * Numeric range validation
> * Complex date format validation
> * Inter-parameter dependencies beyond exclusive groups
> * Conditional validation based on other parameter values
> Would you like me to provide more specific examples of how to use any of these actually implemented features?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)