Validator
_init_
validate
validate_stream
with_metadata
to_runnable
register_validator
ValidationResult
outcomestr - The outcome of the validation. Must be one of “pass” or “fail”.metadataOptional[Dict[str, Any]] - The metadata associated with this validation result.validated_chunkOptional[Any] - The value argument passed to validator.validate or validator.validate_stream.
PassResult
outcomeLiteral[“pass”] - The outcome of the validation. Must be “pass”.value_overrideOptional[Any] - The value to use as an override if validation passes.
FailResult
outcomeLiteral[“fail”] - The outcome of the validation. Must be “fail”.error_messagestr - The error message indicating why validation failed.fix_valueOptional[Any] - The auto-fix value that would be applied if the Validator’s on_fail method is “fix”.error_spansOptional[List[ErrorSpan]] - Segments that caused validation to fail.
ErrorSpan
startint - Starting index relative to the validated chunk.endint - Ending index relative to the validated chunk.reasonstr - Reason validation failed for this chunk.
ValidatorLogs
validator_namestr - The class name of the validatorregistered_namestr - The snake_cased id of the validatorproperty_pathstr - The JSON path to the property being validatedvalue_before_validationAny - The value before validationvalue_after_validationOptional[Any] - The value after validation; could be different ifvalue_overrides orfixes are appliedvalidation_resultOptional[ValidationResult] - The result of the validationstart_timeOptional[datetime] - The time the validation startedend_timeOptional[datetime] - The time the validation endedinstance_idOptional[int] - The unique id of this instance of the validator
ValidatorReference
idOptional[str] - The unique identifier for this Validator. Often the hub id; e.g. guardrails/regex_match. Default None.onOptional[str] - A reference to the property this validator should be applied against. Can be a valid JSON path or a meta-property such aspromptoroutput. Default None.on_failOptional[str] - The OnFailAction to apply during validation. Default None.argsOptional[List[Any]] - Positional arguments. Default None.kwargsOptional[Dict[str, Any]] - Keyword arguments. Default None.