"use strict";
/*
 * @adonisjs/validator
 *
 * (c) Harminder Virk <virk@adonisjs.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.beforeOrEqual = void 0;
const offset_1 = require("./helpers/offset");
const helpers_1 = require("../../Validator/helpers");
const RULE_NAME = 'beforeOrEqual';
const DEFAULT_MESSAGE = 'beforeOrEqual date validation failed';
/**
 * Ensure the value is one of the defined choices
 */
exports.beforeOrEqual = {
    compile: (0, helpers_1.wrapCompile)(RULE_NAME, ['date'], (options) => {
        return (0, offset_1.compile)(RULE_NAME, '<=', options);
    }),
    validate(value, compiledOptions, runtimeOptions) {
        return (0, offset_1.validate)(RULE_NAME, DEFAULT_MESSAGE, value, compiledOptions, runtimeOptions);
    },
};
