"use strict";
/*
 * @adonisjs/http-server
 *
 * (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.RouteMatchers = void 0;
/// <reference path="../../adonis-typings/index.ts" />
const macroable_1 = require("macroable");
/**
 * Shortcut methods for commonly used route matchers
 */
class RouteMatchers extends macroable_1.Macroable {
    /**
     * Enforce value to be a number and also casts it to number data
     * type
     */
    number() {
        return { match: /^[0-9]+$/, cast: (value) => Number(value) };
    }
    /**
     * Enforce value to be formatted as uuid
     */
    uuid() {
        return {
            match: /^[0-9a-zA-F]{8}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{4}-[0-9a-zA-F]{12}$/,
            cast: (value) => value.toLowerCase(),
        };
    }
    /**
     * Enforce value to be formatted as slug
     */
    slug() {
        return { match: /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/ };
    }
}
exports.RouteMatchers = RouteMatchers;
RouteMatchers.macros = {};
RouteMatchers.getters = {};
