Computer scienceBackendKtorKtor Plugins

Request Validation

Validation Function

Report a typo

Assuming you have a POST request with a body of type String, you need to return an invalid result with the message: Request should not start with 'Admin'

install(RequestValidation) {
    validate<String> { bodyText ->
        if (!bodyText.startsWith("Admin")) {
            /* your code here */
        } else {
            ValidationResult.Valid
        }
    }
}
Enter a short text
___

Create a free account to access the full topic