Sanity Library Reference Docs
    Preparing search index...

    Interface ValidationError

    The shape that can be returned from a custom validator to be converted into a validation marker by the validation logic. Inside of a custom validator, you can return an array of these in order to specify multiple paths within an object or array.

    interface ValidationError {
        children?: ValidationMarker[];
        message: string;
        operation?: "AND" | "OR";
        path?: Path;
        paths?: Path[];
        cloneWithMessage(message: string): ValidationError;
    }
    Index

    Methods

    Properties

    children?: ValidationMarker[]

    Unused. Was used to store the results from .either() /.all()

    message: string

    The message describing why the value is not valid. This message will be included in the validation markers after validation has finished running.

    operation?: "AND" | "OR"

    Unused. Was used to signal if this error came from an .either()/.all().

    path?: Path

    If writing a custom validator, you can return validation messages to specific path inside of the current value (object or array) by populating this path prop.

    NOTE: This path is relative to the current value and not relative to the document.

    paths?: Path[]

    Same as path but allows more than one value. If provided, the same message will create two markers from each path with the same message provided.

    prefer path