Ordered Deployment Configuration Validator
Problem statement
Validate a four-element string array values in this exact order: app_name, port, debug_mode, and max_connections. Stop at the first failed field.
app_namemust be non-empty and contain at most50characters. Otherwise useapp_name must be non-empty and max 50 characters.portmust be a strict base-10 integer string from1024through65535, inclusive. Otherwise useport must be between 1024 and 65535.debug_modeis case-insensitive and must betrueorfalse. Otherwise usedebug_mode must be true or false.max_connectionsmust be a strict base-10 integer string from1through10000, inclusive. Otherwise usemax_connections must be between 1 and 10000.
Inputs are not trimmed. A strict integer string contains an optional leading + or - followed by one or more digits.
Encode a successful typed configuration as ["ok", app_name, port, debug_mode, max_connections], using normalized decimal integers and a lowercase boolean. Encode a failure as ["error", message].
Function
validateDeploymentConfig(values: String[]) → String[]Examples
Example 1
values = ["payments","8080","TRUE","250"]return = ["ok","payments","8080","true","250"]All four fields pass in order. The integer strings are normalized and TRUE becomes true.
Example 2
values = ["","80","maybe","0"]return = ["error","app_name must be non-empty and max 50 characters"]Validation stops immediately at the empty app_name, even though later fields are also invalid.
Example 3
values = ["api","65536","false","100"]return = ["error","port must be between 1024 and 65535"]The application name is valid, but 65536 is one above the allowed port range.
Constraints
values.length == 4.- Each element of
valuesis a non-null string. - Inputs are validated exactly as received, except
debug_modeis converted to lowercase.