Marc Cawood
·Positivity ✌️

Validate Upload Size using IF

I am trying to validate the file size of an upload and throw an error if it's over 100KB.

The IF component doesn't seem to parse avatar_file.size as expected and declares it's undefined. Interestingly the debugger shows the value correctly.

Using the Expression editor we get to$input.avatar_file.size but this doesn't work either. As can be seen the condition $input.avatar_file.size > 100000 is indeed true but the ELSE branch is called instead of THEN Throw error:

It's confusing that there are apparently 2 different ways of referencing variables which are incompatible or rather that neither way seems to work.

5 replies