UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

120 lines 4.91 kB
import { BoxSdkError } from '../box/errors.js'; import { sdIsString } from '../serialization/json.js'; import { sdIsMap } from '../serialization/json.js'; export 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; } } } export function serializeSignRequestSignerInputCustomValidationValidationTypeField(val) { return val; } export function deserializeSignRequestSignerInputCustomValidationValidationTypeField(val) { if (val == 'custom') { return val; } if (sdIsString(val)) { return val; } throw new BoxSdkError({ message: "Can't deserialize SignRequestSignerInputCustomValidationValidationTypeField", }); } export function serializeSignRequestSignerInputCustomValidation(val) { return { ['validation_type']: serializeSignRequestSignerInputCustomValidationValidationTypeField(val.validationType), ['custom_regex']: val.customRegex, ['custom_error_message']: val.customErrorMessage, }; } export function deserializeSignRequestSignerInputCustomValidation(val) { if (!sdIsMap(val)) { throw new BoxSdkError({ message: 'Expecting a map for "SignRequestSignerInputCustomValidation"', }); } if (val.validation_type == void 0) { throw new BoxSdkError({ message: 'Expecting "validation_type" of type "SignRequestSignerInputCustomValidation" to be defined', }); } const validationType = deserializeSignRequestSignerInputCustomValidationValidationTypeField(val.validation_type); if (!(val.custom_regex == void 0) && !sdIsString(val.custom_regex)) { throw new 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) && !sdIsString(val.custom_error_message)) { throw new 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, }; } export function serializeSignRequestSignerInputCustomValidationInput(val) { return { ['validationType']: val.validationType == void 0 ? val.validationType : serializeSignRequestSignerInputCustomValidationValidationTypeField(val.validationType), ['custom_regex']: val.customRegex, ['custom_error_message']: val.customErrorMessage, }; } export function deserializeSignRequestSignerInputCustomValidationInput(val) { if (!sdIsMap(val)) { throw new BoxSdkError({ message: 'Expecting a map for "SignRequestSignerInputCustomValidationInput"', }); } const validationType = val.validationType == void 0 ? void 0 : deserializeSignRequestSignerInputCustomValidationValidationTypeField(val.validationType); if (!(val.custom_regex == void 0) && !sdIsString(val.custom_regex)) { throw new 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) && !sdIsString(val.custom_error_message)) { throw new 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