AdonisJS v6 is here. Learn more in our release blog post.

equalTo

Validates the value to be equal to a provided value.

import { schema, rules } from '@ioc:Adonis/Core/Validator'
{
country: schema.string([
rules.equalTo('IN')
])
}

If the provided value is computed at runtime and you are using schema caching, then you must make use of refs.

import { schema } from '@ioc:Adonis/Core/Validator'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class CreateUserValidator {
constructor(protected ctx: HttpContextContract) {}
public refs = schema.refs({
teamsCountry: getTeamCountryFromSomeWhere(),
})
public schema = schema.create({
country: schema.string([
rules.equalTo(this.refs.teamsCountry)
]),
})
public cacheKey = this.ctx.routeKey
}