fun validate()

in jetbrains-core/src/software/aws/toolkits/jetbrains/services/schemas/code/DownloadCodeForSchemaDialog.kt [258:278]


    fun validate(view: DownloadCodeForSchemaPanel): ValidationInfo? {
        if (view.version.selectedIndex < 0) {
            return ValidationInfo(message("schemas.schema.download_code_bindings.validation.version_required"), view.version)
        }

        if (view.language.selectedIndex < 0) {
            return ValidationInfo(message("schemas.schema.download_code_bindings.validation.language_required"), view.language)
        }

        val locationText = view.location.text
        if (locationText.isEmpty()) {
            return ValidationInfo(message("schemas.schema.download_code_bindings.validation.fileLocation_required"), view.location)
        }

        val file = File(locationText)
        if (!file.exists() || !file.isDirectory) {
            return ValidationInfo(message("schemas.schema.download_code_bindings.validation.fileLocation_invalid"), view.location)
        }

        return null
    }