• Validates a job ID object against specified constraints.

    Parameters

    • jobIdObj: JobIdValidable

      The job ID object to validate, containing value and optional constraints.

    • Optionalverbose: boolean = false

      If true, logs validation result to the console.

    Returns boolean

    • True if the job ID meets all constraints, false otherwise.

    validateJobId

    Checks a job ID against the constraints defined in the JobIdValidable object:

    • If required is true, ensures the value is not empty.
    • If minLength is set, ensures the value meets the minimum length.
    • If maxLength is set, ensures the value does not exceed the maximum length.
    • If pattern is set, ensures the value matches the regular expression. Trims the value before validation. Logs a message if verbose is true.

    JobIdValidable - Interface defining job ID validation constraints.

    const jobId = { value: 'ncbiblast-I20200317-103136-0485-5599422-np2', minLength: 35,
    pattern: /([a-z_])*-([A-Z0-9])*-\d*-\d*-\d*-(np2|p1m|p2m)$/ };
    console.log(validateJobId(jobId)); // Outputs: true

    const invalidJobId = { value: 'invalid', required: true };
    console.log(validateJobId(invalidJobId, true)); // Outputs: false (logs "JobId "invalid" is not valid!")