Sanity Library Reference Docs
    Preparing search index...

    Interface Rule

    interface Rule {
        valueOfField: (path: string | string[]) => FieldReference;
    }
    Index

    Properties

    Properties

    valueOfField: (path: string | string[]) => FieldReference

    Takes in a path and returns an object with a symbol.

    When the validation lib sees this symbol, it will use the provided path to get a value from the current field's parent and use that value as the input to the Rule.

    The path that's given is forwarded to lodash/get

    fields: [
    // ...
    {
    // ...
    name: 'highestTemperature',
    type: 'number',
    validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
    // ...
    },
    ]