Following code (shortened for simplicity):
<kendo-fileselect
id="files"
formControlName="files"
[restrictions]="this.fileRestrictions"
(select)="onFileSelect($event)">
<ng-template kendoFileSelectFileInfoTemplate let-files>
---- shows name and validationerrors ----
</ng-template>
</kendo-fileselect>
async onFileSelect(ev: SelectEvent) {
ev.files.forEach(currentFile => {
if (currentFile.rawFile) {
this.readFile(currentFile.rawFile).then(content => {
let attachment = (<AttachmentModel>{filename: currentFile.name, content: content});
this.attachmentClient.isValid(attachment, this.tenant).subscribe(
isValid => {
if (!isValid) {
currentFile.validationErrors = currentFile.validationErrors ?? [];
currentFile.validationErrors.push("malwareFound");
} } ); } ); } }); }
Explaination: I'm checking for malware here (via this.attachmentClient.isValid on server-side).
My problem: It shows the validationerror, but still adds the file to value of the control. For example it doesn't add a file with a wrong extension (restricted via kendo-fileselect restrictions) How can I set my malware-file to not end up in value? I've tried ev.preventDefault(), but this removes the file completely from the list (and I don't see the validationerror)
Screenshot:
- first file: not allowed filetype -> is not in value of control
- second file: malware -> is still in value of control
Regards