/**
 * Ensures the value of the current field (the one the validator is on) matches the one of the target field.
 * @param target any other field
 * @returns a validator function that will be run by the smart form during the client-side validation stage
 */
export const mustMatch = (target) => {
    return (data, path, label) => {
        if (!(path === null || path === void 0 ? void 0 : path.length) || !(target === null || target === void 0 ? void 0 : target.length) || !data)
            return [];
        const value1 = data === null || data === void 0 ? void 0 : data[target];
        const value2 = data === null || data === void 0 ? void 0 : data[path];
        if (!(value1 === null || value1 === void 0 ? void 0 : value1.length) || !(value2 === null || value2 === void 0 ? void 0 : value2.length) || value1 === value2)
            return [];
        return [
            {
                instancePath: `/${path}`,
                message: `Needs to match ${target}`,
                schemaPath: '',
                keyword: '',
                params: {},
            },
        ];
    };
};
//# sourceMappingURL=validation.js.map