{"version":3,"file":"Validate.mjs","sources":["../../src/Validate.ts"],"sourcesContent":["/**\n * The types of validations supported\n */\nexport var ValidationType;\n(function (ValidationType) {\n    ValidationType[\"GT\"] = \"gt\";\n    ValidationType[\"LT\"] = \"lt\";\n    ValidationType[\"GTE\"] = \"gte\";\n    ValidationType[\"LTE\"] = \"lte\";\n    ValidationType[\"MIN_LENGTH\"] = \"minLength\";\n    ValidationType[\"MAX_LENGTH\"] = \"maxLength\";\n    ValidationType[\"STARTS_WITH\"] = \"startsWith\";\n    ValidationType[\"ENDS_WITH\"] = \"endsWith\";\n    ValidationType[\"MATCHES\"] = \"matches\";\n})(ValidationType || (ValidationType = {}));\n/**\n * Creates an internal validation builder for a specific field type\n * @typeParam T - The type of the field being validated\n */\nfunction createValidationBuilderInternal() {\n    const rules = [];\n    const builder = {\n        /**\n         * Validates that a numeric field is greater than the specified value\n         * @param value - The value that the field must be greater than\n         * @param errorMessage - Optional custom error message\n         */\n        gt(value, errorMessage) {\n            rules.push({ type: ValidationType.GT, value, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a numeric field is less than the specified value\n         * @param value - The value that the field must be less than\n         * @param errorMessage - Optional custom error message\n         */\n        lt(value, errorMessage) {\n            rules.push({ type: ValidationType.LT, value, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a numeric field is greater than or equal to the specified value\n         * @param value - The value that the field must be greater than or equal to\n         * @param errorMessage - Optional custom error message\n         */\n        gte(value, errorMessage) {\n            rules.push({ type: ValidationType.GTE, value, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a numeric field is less than or equal to the specified value\n         * @param value - The value that the field must be less than or equal to\n         * @param errorMessage - Optional custom error message\n         */\n        lte(value, errorMessage) {\n            rules.push({ type: ValidationType.LTE, value, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a numeric field is positive. We use gt(0) internally to achieve this.\n         * @param errorMessage - Optional custom error message\n         */\n        positive(errorMessage) {\n            rules.push({ type: ValidationType.GT, value: 0, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a numeric field is negative. We use lt(0) internally to achieve this.\n         * @param errorMessage - Optional custom error message\n         */\n        negative(errorMessage) {\n            rules.push({ type: ValidationType.LT, value: 0, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a string field has at least the specified length\n         * @param length - The minimum length required\n         * @param errorMessage - Optional custom error message\n         */\n        minLength(length, errorMessage) {\n            rules.push({ type: ValidationType.MIN_LENGTH, value: length, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a string field does not exceed the specified length\n         * @param length - The maximum length allowed\n         * @param errorMessage - Optional custom error message\n         */\n        maxLength(length, errorMessage) {\n            rules.push({ type: ValidationType.MAX_LENGTH, value: length, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a string field starts with the specified prefix\n         * @param prefix - The prefix the string must start with\n         * @param errorMessage - Optional custom error message\n         */\n        startsWith(prefix, errorMessage) {\n            rules.push({ type: ValidationType.STARTS_WITH, value: prefix, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a string field ends with the specified suffix\n         * @param suffix - The suffix the string must end with\n         * @param errorMessage - Optional custom error message\n         */\n        endsWith(suffix, errorMessage) {\n            rules.push({ type: ValidationType.ENDS_WITH, value: suffix, errorMessage });\n            return this;\n        },\n        /**\n         * Validates that a string field matches the specified regular expression pattern\n         * @param pattern - The regex pattern the string must match\n         * @param errorMessage - Optional custom error message\n         */\n        matches(pattern, errorMessage) {\n            rules.push({ type: ValidationType.MATCHES, value: pattern, errorMessage });\n            return this;\n        },\n        /**\n         * Returns all the validation rules defined by this builder\n         */\n        getRules() {\n            return rules;\n        }\n    };\n    return builder;\n}\n/**\n * Creates a type-safe validation builder for a specific field type with access to get the rules\n * @returns An object containing the validation builder and a function to get the rules\n */\nexport function createValidationBuilder() {\n    const internalBuilder = createValidationBuilderInternal();\n    return {\n        builder: internalBuilder,\n        getRules: () => internalBuilder.getRules()\n    };\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACU,IAAC;AACX,CAAC,U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