> ## Documentation Index
> Fetch the complete documentation index at: https://docs.snapshot.box/llms.txt
> Use this file to discover all available pages before exploring further.

# Validation strategies

## What is a validation strategy?

A voting validation is a JavaScript function that returns a boolean (`true` or `false`) for the connected account. Voting validations are being used on Snapshot to decide if an **account can vote** or **create a proposal** in a specific space. Each space can use one voting validation for all of its proposals at a time. While voting strategies calculate the Voting Power mainly on the basis of the monetary assets, the validation strategy can serve as a protection against **Sybil attacks**. It can take into consideration how many POAPs an account owns or track the account activity to assess if the account is a bot or a **real human**.

The **default** validation is checking if the address has **any voting power.** If the voting power is higher than `0` the connected account is validated. A validation strategy can send a call to a node or subgraph.

When setting the Validation Strategy up it’s important to keep in mind that it is **meant to make it difficult for users outside of your community to post scam proposals or post spam votes.**

Therefore for Proposal Validation make sure to use a **high threshold**, for example \$100 worth of your organization’s token. A good idea would be to check the holdings of previous proposal creators, both legitimate and scammers, to assess a reasonable value.

> [!NOTE]
>
> Spaces are required to use **Proposal Validation**. Learn how to set it up on this page or read [**our article**](https://snapshot.mirror.xyz/-uSylOUP82hGAyWUlVn4lCg9ESzKX9QCvsUgvv-ng84)**.**

> [!NOTE]
>
> Spaces using only a [ticket strategy](https://snapshot.box/#/strategy/ticket) are required to set a Voting Validation to secure their spaces and ensure a fair voting process preventing spam. Learn here how to set it up: [#voting-validation-in-space-settings](#voting-validation-in-space-settings)

## How to use validation strategies:

Validation strategies can be used for two purposes:

* proposal validation - determine if the account can create a new proposal,
* voting validation - determine if the account can take part in the voting process.

#### Proposal Validation in Space Settings

Head to **Proposals** tab in the sidebar to update the configuration:

![](https://mintcdn.com/snapshotlabs/6skWh-3uFxAZWSRt/images/82.png?fit=max\&auto=format\&n=6skWh-3uFxAZWSRt\&q=85\&s=0ea80b8a1744f340c7544c3e01017bbf)

#### Voting Validation in Space Settings

Head to **Voting** tab in the sidebar to update the configuration:

![](https://mintcdn.com/snapshotlabs/6skWh-3uFxAZWSRt/images/83.png?fit=max\&auto=format\&n=6skWh-3uFxAZWSRt\&q=85\&s=ff8375fdc4d40e411313855491105c8b)

If you want to allow addresses with any voting power to vote you can use the default voting validation.

![](https://mintcdn.com/snapshotlabs/pdueIdTfoQVSZJ1p/images/149.png?fit=max\&auto=format\&n=pdueIdTfoQVSZJ1p\&q=85\&s=571493188567845d189712e9c13ca918)

> [!NOTE]
>
> If you are using only a [ticket](https://snapshot.box/#/strategy/ticket) Voting Strategy for your space you are required to use a [Gitcoin Passport Validation](#validation-strategy-example-gitcoin-passport) for Voting to protect your space from spam votes.

## Authors only mode

If you wish to limit proposal creators to Admins, Moderators and Authors only, you can do so by enabling the **Authors only** setting in the **Proposal** tab in the space settings. Make sure to give the Author role to the users you trust!

![](https://mintcdn.com/snapshotlabs/6skWh-3uFxAZWSRt/images/81.png?fit=max\&auto=format\&n=6skWh-3uFxAZWSRt\&q=85\&s=b8adc8b93383c504bf7e698d77eaeb97)

## Validation strategy example: Basic

The Basic validation strategy allows you to use existing Voting Strategies configured for your space or define a custom setup to determine if a user is eligible to create a proposal or cast a vote.

In order to use existing setup of Voting Strategies you can simply chose **Basic Validation** and define a required threshold as on the screenshot below. `100` corresponds to user's Voting Power calculated on the basis of the Voting Strategies.

![Use current setup and define a strong threshold to avoid spam in your space.](https://mintcdn.com/snapshotlabs/6skWh-3uFxAZWSRt/images/79.png?fit=max\&auto=format\&n=6skWh-3uFxAZWSRt\&q=85\&s=3a59421b4db3fe2786e7e53ee042c831)

If you wish to use a different configuration, toggle the **Use custom strategies** button and define the strategies for your use case:

![Use a custom setup using various Voting Strategies to calculate if a user is eligible to create a proposal or vote.](https://mintcdn.com/snapshotlabs/6skWh-3uFxAZWSRt/images/80.png?fit=max\&auto=format\&n=6skWh-3uFxAZWSRt\&q=85\&s=2f652dda3c9196bd15d7fa0e10496bfd)

#### Validate at the latest block

By default, voting validation checks the strategies at the proposal's snapshot block, so anyone who receives a token after the proposal is created cannot vote on it. If your space gates voting with a non-transferable token (SBT), tick **Validate at the latest block** in the Basic validation settings. The strategies are then checked at the current block, so a member can verify, mint their token and vote right away.

> [!WARNING]
>
> Only use this option with non-transferable tokens. With a transferable token, the same token could be moved between wallets to pass validation multiple times.

The option applies to voting validation only and takes effect for proposals created after it is enabled. A typical setup for one vote per verified person: the [ticket](https://snapshot.box/#/strategy/ticket) Voting Strategy, Basic voting validation with a minimum score of `1`, a custom `erc721` strategy pointing at the SBT contract, and **Validate at the latest block** enabled.

## Validation strategy example: Gitcoin Passport

Validation strategy built together with **Gitcoin Passport.** You can select individual or multiple stamps that matter for your space. You can also decide if they need to meet all of these criteria or only one. The more criteria you select, the more sybil resistant your space is.

![](https://mintcdn.com/snapshotlabs/kgogJ6O83n1DRfzQ/images/241.png?fit=max\&auto=format\&n=kgogJ6O83n1DRfzQ\&q=85\&s=7e8fb1f929ac8f539374e3d371b8d82b)

#### Implementation

Have a look at the example of the Gitcoin Passport validation strategy.

[https://github.com/snapshot-labs/score-api/blob/master/src/strategies/validations/passport-gated/index.ts](https://github.com/snapshot-labs/score-api/blob/master/src/strategies/validations/passport-gated/index.ts)

```javascript theme={null}
import snapshot from '@snapshot-labs/snapshot.js';
import Validation from '../validation';
import {
  getPassport,
  getVerifiedStamps,
  hasValidIssuanceAndExpiration
} from '../passport-weighted/helper';

export default class extends Validation {
  public id = 'passport-gated';
  public github = 'snapshot-labs';
  public version = '0.1.0';

  async validate(): Promise<boolean> {
    const requiredStamps = this.params.stamps;
    const passport: any = await getPassport(this.author);
    if (!passport) return false;
    if (!passport.stamps?.length || !requiredStamps?.length) return false;

    const verifiedStamps: any[] = await getVerifiedStamps(
      passport,
      this.author,
      requiredStamps.map((stamp) => ({
        id: stamp
      }))
    );
    if (!verifiedStamps.length) return false;

    const provider = snapshot.utils.getProvider(this.network);
    const proposalTs = (await provider.getBlock(this.snapshot)).timestamp;

    const operator = this.params.operator;

    // check issuance and expiration
    const validStamps = verifiedStamps
      .filter((stamp) =>
        hasValidIssuanceAndExpiration(stamp.credential, proposalTs)
      )
      .map((stamp) => stamp.provider);

    if (operator === 'AND') {
      return requiredStamps.every((stamp) => validStamps.includes(stamp));
    } else if (operator === 'OR') {
      return requiredStamps.some((stamp) => validStamps.includes(stamp));
    } else {
      return false;
    }
  }
}
```

Voting validation can be specified in your space settings at `https://snapshot.box/#/s:<SPACE ADDRESS>/settings`.

## Create a custom validation

The possibilities are endless! You can build a custom validation strategy for your space. Please have a look at [validation-strategy](https://docs.snapshot.box/developer-guides/validation-strategy.md) for more details.

## Find more voting validations here:

[https://github.com/snapshot-labs/score-api/tree/master/src/strategies/validations](https://github.com/snapshot-labs/score-api/tree/master/src/strategies/validations)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.