"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignRequestSignerInputCustomValidation = void 0;
exports.serializeSignRequestSignerInputCustomValidationValidationTypeField = serializeSignRequestSignerInputCustomValidationValidationTypeField;
exports.deserializeSignRequestSignerInputCustomValidationValidationTypeField = deserializeSignRequestSignerInputCustomValidationValidationTypeField;
exports.serializeSignRequestSignerInputCustomValidation = serializeSignRequestSignerInputCustomValidation;
exports.deserializeSignRequestSignerInputCustomValidation = deserializeSignRequestSignerInputCustomValidation;
exports.serializeSignRequestSignerInputCustomValidationInput = serializeSignRequestSignerInputCustomValidationInput;
exports.deserializeSignRequestSignerInputCustomValidationInput = deserializeSignRequestSignerInputCustomValidationInput;
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
class SignRequestSignerInputCustomValidation {
    /**
     * Defines the validation format for the text input as custom.
     * A custom regular expression is used for validation. */
    validationType = 'custom';
    /**
     * Regular expression used for validation. */
    customRegex;
    /**
     * Error message shown if input fails custom regular expression validation. */
    customErrorMessage;
    rawData;
    constructor(fields) {
        if (fields.validationType !== undefined) {
            this.validationType = fields.validationType;
        }
        if (fields.customRegex !== undefined) {
            this.customRegex = fields.customRegex;
        }
        if (fields.customErrorMessage !== undefined) {
            this.customErrorMessage = fields.customErrorMessage;
        }
        if (fields.rawData !== undefined) {
            this.rawData = fields.rawData;
        }
    }
}
exports.SignRequestSignerInputCustomValidation = SignRequestSignerInputCustomValidation;
function serializeSignRequestSignerInputCustomValidationValidationTypeField(val) {
    return val;
}
function deserializeSignRequestSignerInputCustomValidationValidationTypeField(val) {
    if (val == 'custom') {
        return val;
    }
    if ((0, json_1.sdIsString)(val)) {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize SignRequestSignerInputCustomValidationValidationTypeField",
    });
}
function serializeSignRequestSignerInputCustomValidation(val) {
    return {
        ['validation_type']: serializeSignRequestSignerInputCustomValidationValidationTypeField(val.validationType),
        ['custom_regex']: val.customRegex,
        ['custom_error_message']: val.customErrorMessage,
    };
}
function deserializeSignRequestSignerInputCustomValidation(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "SignRequestSignerInputCustomValidation"',
        });
    }
    if (val.validation_type == void 0) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting "validation_type" of type "SignRequestSignerInputCustomValidation" to be defined',
        });
    }
    const validationType = deserializeSignRequestSignerInputCustomValidationValidationTypeField(val.validation_type);
    if (!(val.custom_regex == void 0) && !(0, json_1.sdIsString)(val.custom_regex)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "custom_regex" of type "SignRequestSignerInputCustomValidation"',
        });
    }
    const customRegex = val.custom_regex == void 0 ? void 0 : val.custom_regex;
    if (!(val.custom_error_message == void 0) &&
        !(0, json_1.sdIsString)(val.custom_error_message)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "custom_error_message" of type "SignRequestSignerInputCustomValidation"',
        });
    }
    const customErrorMessage = val.custom_error_message == void 0 ? void 0 : val.custom_error_message;
    return {
        validationType: validationType,
        customRegex: customRegex,
        customErrorMessage: customErrorMessage,
    };
}
function serializeSignRequestSignerInputCustomValidationInput(val) {
    return {
        ['validationType']: val.validationType == void 0
            ? val.validationType
            : serializeSignRequestSignerInputCustomValidationValidationTypeField(val.validationType),
        ['custom_regex']: val.customRegex,
        ['custom_error_message']: val.customErrorMessage,
    };
}
function deserializeSignRequestSignerInputCustomValidationInput(val) {
    if (!(0, json_2.sdIsMap)(val)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting a map for "SignRequestSignerInputCustomValidationInput"',
        });
    }
    const validationType = val.validationType == void 0
        ? void 0
        : deserializeSignRequestSignerInputCustomValidationValidationTypeField(val.validationType);
    if (!(val.custom_regex == void 0) && !(0, json_1.sdIsString)(val.custom_regex)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "custom_regex" of type "SignRequestSignerInputCustomValidationInput"',
        });
    }
    const customRegex = val.custom_regex == void 0 ? void 0 : val.custom_regex;
    if (!(val.custom_error_message == void 0) &&
        !(0, json_1.sdIsString)(val.custom_error_message)) {
        throw new errors_1.BoxSdkError({
            message: 'Expecting string for "custom_error_message" of type "SignRequestSignerInputCustomValidationInput"',
        });
    }
    const customErrorMessage = val.custom_error_message == void 0 ? void 0 : val.custom_error_message;
    return {
        validationType: validationType,
        customRegex: customRegex,
        customErrorMessage: customErrorMessage,
    };
}
//# sourceMappingURL=signRequestSignerInputCustomValidation.js.map