mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
137 lines
3.6 KiB
JSON
137 lines
3.6 KiB
JSON
{
|
|
"schema_version": "2.1.0",
|
|
"package": "json_script_example",
|
|
"description": "Validation utility functions",
|
|
|
|
"exports": {
|
|
"functions": ["isEmail", "isNotEmpty", "validateRange"]
|
|
},
|
|
|
|
"functions": [
|
|
{
|
|
"id": "is_email_fn",
|
|
"name": "isEmail",
|
|
"description": "Check if string is a valid email",
|
|
"exported": true,
|
|
"params": [
|
|
{"name": "email", "type": "string"}
|
|
],
|
|
"returnType": "boolean",
|
|
"body": [
|
|
{
|
|
"type": "comment",
|
|
"text": "Basic email validation - contains @ and domain"
|
|
},
|
|
{
|
|
"type": "const_declaration",
|
|
"name": "hasAt",
|
|
"value": {
|
|
"type": "binary_expression",
|
|
"left": {
|
|
"type": "call_expression",
|
|
"callee": "$ref:imports.string.indexOf",
|
|
"args": ["$ref:params.email", "@"]
|
|
},
|
|
"operator": ">",
|
|
"right": 0
|
|
}
|
|
},
|
|
{
|
|
"type": "const_declaration",
|
|
"name": "hasDot",
|
|
"value": {
|
|
"type": "binary_expression",
|
|
"left": {
|
|
"type": "call_expression",
|
|
"callee": "$ref:imports.string.lastIndexOf",
|
|
"args": ["$ref:params.email", "."]
|
|
},
|
|
"operator": ">",
|
|
"right": {
|
|
"type": "call_expression",
|
|
"callee": "$ref:imports.string.indexOf",
|
|
"args": ["$ref:params.email", "@"]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "return",
|
|
"value": {
|
|
"type": "logical_expression",
|
|
"left": "$ref:local.hasAt",
|
|
"operator": "&&",
|
|
"right": "$ref:local.hasDot"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"id": "is_not_empty_fn",
|
|
"name": "isNotEmpty",
|
|
"description": "Check if string is not empty after trimming",
|
|
"exported": true,
|
|
"params": [
|
|
{"name": "str", "type": "string"}
|
|
],
|
|
"returnType": "boolean",
|
|
"body": [
|
|
{
|
|
"type": "const_declaration",
|
|
"name": "trimmed",
|
|
"value": {
|
|
"type": "call_expression",
|
|
"callee": "$ref:imports.string.trim",
|
|
"args": ["$ref:params.str"]
|
|
}
|
|
},
|
|
{
|
|
"type": "return",
|
|
"value": {
|
|
"type": "binary_expression",
|
|
"left": {
|
|
"type": "member_access",
|
|
"object": "$ref:local.trimmed",
|
|
"property": "length"
|
|
},
|
|
"operator": ">",
|
|
"right": 0
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"id": "validate_range_fn",
|
|
"name": "validateRange",
|
|
"description": "Check if number is within range",
|
|
"exported": true,
|
|
"params": [
|
|
{"name": "value", "type": "number"},
|
|
{"name": "min", "type": "number"},
|
|
{"name": "max", "type": "number"}
|
|
],
|
|
"returnType": "boolean",
|
|
"body": [
|
|
{
|
|
"type": "return",
|
|
"value": {
|
|
"type": "logical_expression",
|
|
"left": {
|
|
"type": "binary_expression",
|
|
"left": "$ref:params.value",
|
|
"operator": ">=",
|
|
"right": "$ref:params.min"
|
|
},
|
|
"operator": "&&",
|
|
"right": {
|
|
"type": "binary_expression",
|
|
"left": "$ref:params.value",
|
|
"operator": "<=",
|
|
"right": "$ref:params.max"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|