All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cc.unitmesh.prompt.validate.JsonValidator.kt Maven / Gradle / Ivy

package cc.unitmesh.prompt.validate

import com.google.gson.JsonParser

/**
 * JsonValidator will validate is input is valid json. If input is invalid, will return false.
 */
class JsonValidator(override val input: String) : Validator {
    override fun validate(): Boolean {
        return try {
            JsonParser.parseString(input)
            true
        } catch (e: Exception) {
            false
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy