chungchunwang / Budibase-File-Upload

Upload files in your Budibase app!
MIT License
22 stars 11 forks source link

Feature: Add validation #5

Closed JEQ7 closed 1 year ago

JEQ7 commented 1 year ago

Hi I'm currently using the Budibase https://github.com/chungchunwang/Budibase-File-Upload plugin

And I want to make this field required

I try making the field column required in the database and then validate form But still I cant make the Budibase-File-Upload field required

(At less one file should be upload ) Any suggestions??

chungchunwang commented 1 year ago

Hi! Under the current implementation, an empty field would be considered as satisfying Budibase's "required" validation, as an empty JSON array is still stored in the field. However, you can circumvent this by adding another validation step that disallows the following string value: .[]. - If you are using encoding protection or [] - If you are not using encoding protection

Also keep the required validation step as well - an empty array is not stored if the plugin is not clicked in the form.

chungchunwang commented 1 year ago

Obviously, it would be better for the plugin to not store an empty array at all if there is not file stored; this would enable the required validation to work. I'm really busy as of the moment, but I will add this if I get the time.

JEQ7 commented 1 year ago

Obviously, it would be better for the plugin to not store an empty array at all if there is not file stored; this would enable the required validation to work. I'm really busy as of the moment, but I will add this if I get the time.

That will be so great and helpful for us!! We will wait for new release for the "Budibase-File-Upload" plugin

Thanks in advance @chungchunwang :)

chungchunwang commented 1 year ago

@JEQ7 Should be fixed! Make sure to update the plugin in Budibase!

JEQ7 commented 1 year ago

@JEQ7 Should be fixed! Make sure to update the plugin in Budibase!

Dear @chungchunwang ,, I have update the plugin but it still save with empty files! See the attached video

Appreciate your support!

https://github.com/chungchunwang/Budibase-File-Upload/assets/81333578/56af3327-0210-4898-a15c-9680ef796ff3

chungchunwang commented 1 year ago

Hi! Can I see what validation rule you have on the file upload field?

chungchunwang commented 1 year ago

Oh, never mind, I see the problem. There is no validation field on the component at all. Will try to add this.

JEQ7 commented 1 year ago

Yes exactly it's only have an opinion for conditions to set

chungchunwang commented 1 year ago

Hi @JEQ7! Ok, it should be fixed. Try updating again. There will now be a validation field on the object for you to set required on.

JEQ7 commented 1 year ago

Hi @chungchunwang

It did work fine But I have problem with the error message can you delete that and let my write whatever I want?

It's seems that there is already default error message, I want to be able to edit that!

if it will be editable will help me cause sometimes I will the to change the error message

Kind regards appreciate your support!:)

See the attached pic

image

image

chungchunwang commented 1 year ago

Hi! That is not an error message I set, maybe it could be caused by something else in your project? I do not get any popup messages at all on my end. Instead, the message shows up like this: image Currently the red error message only shows up if you upload a file and then delete it. I could not get it to update if the user attempts to submit the form. Instead, submitting the form will quietly fail, meaning that the submission will not go through as long as the requirement is not satisfied. Besides the slight UI issue, this should solve your issue of not allowing empty fields. Maybe add a bit of text at the bottom of the form indicating to the user that the form won't submit if they don't upload a file.

chungchunwang commented 1 year ago

By the way, sorry for the sudden influx of new version notifications - I am not at my normal computer and thus do not have the Budibase dev tool installed. Thus, I'm just publishing changes and then testing the compiled plugin.

chungchunwang commented 1 year ago

I have asked for help here: https://github.com/Budibase/budibase/discussions/10582 I'll update the plugin as soon as I figure out how to solve the issue.

JEQ7 commented 1 year ago

I have made it work correctly! Thanks @chungchunwang for your help and support :)

chungchunwang commented 1 year ago

Great to hear!

chungchunwang commented 1 year ago

Currently the red error message only shows up if you upload a file and then delete it. I could not get it to update if the user attempts to submit the form. Instead, submitting the form will quietly fail, meaning that the submission will not go through as long as the requirement is not satisfied.

This should be fixed now! Turns out it was related to this default value issue #8. image