FileUploadBuilder

export declare class FileUploadBuilder extends ComponentBuilder<APIFileUploadComponent>
export declare class FileUploadBuilder extends ComponentBuilder<APIFileUploadComponent>
A builder that creates API-compatible JSON data for file uploads.
constructor(data?)
Creates a new file upload.
Example
Creating a file upload from an API data object:
const fileUpload = new FileUploadBuilder({
custom_id: "file_upload",
min_values: 2,
max_values: 5,
});
const fileUpload = new FileUploadBuilder({
custom_id: "file_upload",
min_values: 2,
max_values: 5,
});
Example
Creating a file upload using setters and API data:
const fileUpload = new FileUploadBuilder({
custom_id: "file_upload",
min_values: 2,
max_values: 5,
}).setRequired();
const fileUpload = new FileUploadBuilder({
custom_id: "file_upload",
min_values: 2,
max_values: 5,
}).setRequired();
NameTypeOptionalDescription
dataPartial<APIFileUploadComponent>YesThe API data to create this file upload with
The API data associated with this component.
Inherited from ComponentBuilder
clearId():this
Clears the id of this component, defaulting to a default incremented id.
Inherited from ComponentBuilder
clearMaxValues():this
Clears the maximum values.
clearMinValues():this
Clears the minimum values.
setCustomId(customId):this
Sets the custom id for this file upload.
NameTypeOptionalDescription
customIdstringNoThe custom id to use
setId(id):this
Sets the id (not the custom id) for this component.
NameTypeOptionalDescription
idnumberNoThe id for this component
Inherited from ComponentBuilder
setMaxValues(maxValues):this
Sets the maximum number of file uploads required.
NameTypeOptionalDescription
maxValuesnumberNoThe maximum values that can be uploaded
setMinValues(minValues):this
Sets the minimum number of file uploads required.
NameTypeOptionalDescription
minValuesnumberNoThe minimum values that must be uploaded
setRequired(required?):this
Sets whether this file upload is required.
NameTypeOptionalDescription
requiredbooleanYesWhether this file upload is required
Serializes this builder to API-compatible JSON data.
Remarks
This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.