FastPrepOrdered Deployment Configuration Validator

Ordered Deployment Configuration Validator

Wells Fargo logoWells Fargo● EasyINTERNOA
Learn

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.

  1. app_name must be non-empty and contain at most 50 characters. Otherwise use app_name must be non-empty and max 50 characters.
  2. port must be a strict base-10 integer string from 1024 through 65535, inclusive. Otherwise use port must be between 1024 and 65535.
  3. debug_mode is case-insensitive and must be true or false. Otherwise use debug_mode must be true or false.
  4. max_connections must be a strict base-10 integer string from 1 through 10000, inclusive. Otherwise use max_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 values is a non-null string.
  • Inputs are validated exactly as received, except debug_mode is converted to lowercase.

More Wells Fargo problems

See Wells Fargo hiring insights
public String[] validateDeploymentConfig(String[] values) {
  // Write your code here
}
values["payments","8080","TRUE","250"]
expected["ok", "payments", "8080", "true", "250"]
Checking account…