API Documentation
Product Validation
The validateProducts
function is used to validate an array of products against a specified target format. It returns an array of validation results for each product.
Function Signature
Parameters
data
: An array of JSON objects representing the products to be validated.targetFormat
: Specifies the structure to validate against, either as ID or object array, seeTargetFormatInput
. If not specified, the default target format will be used.
Return Value
An array of ValidationResult
objects, one for each product, each containing:
valid
: A boolean indicating whether the product passed all validationserrors
: An array of JSON objects containing any validation errors
Usage
Validation Rules
The targetFormat
object specifies the validation rules for each field. The following attributes are supported:
required
: Field must not be emptycapitalized
: Each word in the field must start with an uppercase letterpositiveNumber
: Field must be a positive numbercurrency
: Field must be a valid currency amount
Additional attributes may be available depending on the specific implementation.
Examples
Example 1: Basic Validation
Expected output:
Example 2: Advanced Validation
Expected output:
This updated documentation reflects the new schema structure and provides examples using the GraphQL query format. It also references the TargetFormatInput type, which should be detailed in the Types documentation.