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

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

package cc.unitmesh.prompt.validate

import com.jayway.jsonpath.JsonPath

/**
 * JsonPath will validate is path is valid. If a path is invalid, will return false.
 */
class JsonPathValidator(val expression: String, override val input: String) : Validator {
    override fun validate(): Boolean = try {
        JsonPath.parse(input).read(expression)
        true
    } catch (e: Exception) {
        false
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy