cloud-pipeline
cloud-pipeline copied to clipboard
Add configurable validation for launch parameters
Background
At the moment, Cloud Pipeline does not allow to add custom validation logic for pipelineparameters. It would be nice to extend current config.json to have validation fields for parameters.
Approach
Let's introduce a parameter's validation field of the following structure(s):
...
"parameterA": {
"type": "string",
"required": false,
"validation": [
{
"throw": "parameterA == 'A'",
"message": "parameterA shouldn't be 'A'"
},
{
"throw": "parameterA == 'Z'",
"message": "parameterA shouldn't be 'Z'"
}
]
}
...
"parameterB": {
"type": "string",
"required": false,
"validation": [{
"throw": "parameterA == 'B' && parameterB == 'A'",
"message": "parameterB shouldn't be 'A' when parameterA is 'B'"
}]
}
...
"parameterC": {
"type": "string",
"required": false,
"validation": [{
"throw": "/^abc/i.test(parameterC)",
"message": "parameterC shouldn't start with 'abc'"
}]
}
...
i.e. validation is an array of objects of structure {message, throw}, where:
throw- an expression; if it results to true,messagewill be shown to the user. You can use parameter names, logical operators ("&&", "||", "==", "!="), math operators (>, <, >=, <=, ==), regex expressions ("/regular-expression-goes-here/.test(some-parameter)")message- an error message to be shown to the user ifthrowis true