Description:
Consider the following copybook schema representations:
Example 1:
01 REQUIRED PIC 9.
88 YES VALUE 1.
88 NO VALUE 0.
Example 2:
01 REQUIRED PIC XXX.
88 YES VALUE 'YES'.
88 NO VALUE 'NO '.
These schemas can be considered as enums in a copybook. In both cases, providing a value that does not match the specified conditions should result in an error.
For example, in Example 2, the following code should trigger a validation error:
import ballerina/io;
import ballerinax/copybook;
public function main() returns error? {
copybook:Converter converter = check new ("example2.cbl");
map<json> inputData = {REQUIRED: "N"}; // "N" is not valid here
string|error ascii = converter.toCopybook(inputData);
io:println(ascii);
}
The error details of the returned error might include the following information: {"errors": ["Value 'N ' is invalid for field 'REQUIRED'. Allowed values are: 'YES', 'NO '."]}
Description: Consider the following copybook schema representations:
Example 1:
Example 2:
These schemas can be considered as enums in a copybook. In both cases, providing a value that does not match the specified conditions should result in an error.
For example, in Example 2, the following code should trigger a validation error:
The error details of the returned error might include the following information:
{"errors": ["Value 'N ' is invalid for field 'REQUIRED'. Allowed values are: 'YES', 'NO '."]}
Describe your task(s)
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):