Validate check for null value

Working on it, I’ll let you know the outcome :slight_smile:

Could you show the expression on check_null?

Also, I’ve realized you could do the != null in the expression, and check if it equals to true

I got it somewhat working… its returning 400 with:

How do I tell that form field there is an invalid input base on that response?

Sorry, I am extremely new to wappler.

I am guessing Dynamic Events check if return code and show error, but i don’t see an option to display form error.

Sorry, I deleted it.

Teodor missed that, go back to your old approach :stuck_out_tongue:

Lol … damn this should be easy lol …

Can I run JavaScript on expression ? In the validate part ?

Lol i try faking and invalid validation inside the else logic, but that’s a no-go!

Here is the screenshot you asked for:

It’s not JavaScript but it’s very similar. In the expression try:

{{ customer_numeric_number != null }}

And then in the Validation rules use the “Equals To” true

Alternatively, I’d personally use:

{{ !customer_numeric_number }}

And then in the Validation rules use the “Equals To” true

The Wappler team built their own expression parser/lexer

I tried your 2nd option, this is what’s happening.

In the Workflow tab, click the cog icon and enable Debug Mode

I don’t really know why it’s giving an error though

I do it too!

if it returns a number or null try

{{ customer_numeric_number > 0 }}

Here is the debug:

2022-11-17T19:15:24.517Z server-connect:setup:session init session store { '$type': 'memory', ttl: 86400000 }
2022-11-17T19:15:24.523Z server-connect:setup:upload Upload middleware configured.
2022-11-17T19:15:24.524Z server-connect:setup:routes Api route /api/register/register_customer(.json)? created
App listening at http://localhost:3000
2022-11-17T19:15:27.364Z server-connect:router Serving serverConnect /api/register/register_customer
2022-11-17T19:15:27.366Z server-connect:app Executing action step setvalue
2022-11-17T19:15:27.366Z server-connect:app options: { value: '{{$_POST.customer_number.substr(0,1)}}' }
2022-11-17T19:15:27.367Z server-connect:app Executing action step setvalue
2022-11-17T19:15:27.367Z server-connect:app options: { value: '{{$_POST.customer_number.substr(1, 8).toNumber()}}' }
2022-11-17T19:15:27.367Z server-connect:app Executing action step validate
2022-11-17T19:15:27.367Z server-connect:app options: {
  data: [
    {
      name: 'check_letter',
      value: '{{industry}}',
      rules: [Object],
      fieldName: 'customer_number'
    },
    {
      name: 'check_numeric',
      value: '{{customer_numeric_number}}',
      rules: [Object],
      fieldName: 'customer_number'
    },
    {
      name: 'check_null',
      value: '{{!customer_numeric_number}}',
      rules: [Object],
      fieldName: 'customer_number'
    }
  ]
}
2022-11-17T19:15:27.368Z server-connect:server Got error? TypeError: param.replace is not a function
    at App.equalTo (/Users/krish/OneDrive/dev/backend/lib/validator/core.js:236:46)
    at Object.validateRule (/Users/krish/OneDrive/dev/backend/lib/validator/index.js:93:36)
    at Object.validateData (/Users/krish/OneDrive/dev/backend/lib/validator/index.js:29:37)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async App._exec (/Users/krish/OneDrive/dev/backend/lib/core/app.js:578:30)
    at async App._exec (/Users/krish/OneDrive/dev/backend/lib/core/app.js:545:17)
    at async App.exec (/Users/krish/OneDrive/dev/backend/lib/core/app.js:514:9)
    at async App.define (/Users/krish/OneDrive/dev/backend/lib/core/app.js:496:9)

Do you really need to use the validator for this. It is designed for database field validation.
If looks to me like you are just validating variables, why not just use a core actions -> condition (as teodor suggested)

I opened a bug report for you:

You can maybe wait a day to see if Patrick releases a fix

That doesn’t give the form feedback he wants, only the Validate step does so

1 Like

Thanks, @Apple lifesaver :slight_smile:

I will just add a note to come back later for this validation.

Maybe you can point me in the right direction after database comes back valid … go to step 2 of registration and send the two value over to the next page, so it can be used.

Thanks

It covered in detail here
https://www.youtube.com/playlist?list=PLUjqTJN3byC9W9UFjsV9f9vefe_ZSFQfb

1 Like

Hm… I think I’m not the best person to answer that particular question, haven’t explored much about passing data from one page to another :slight_smile:

Good luck, and check the videos Hyperbytes linked!

Thank @Hyperbytes been watching as i build :slight_smile:

@Apple after thinking of what @Hyperbytes suggested >0

I tried this and it work :slight_smile:

1 Like

Glad it solved the issue. You could also have considered browser validation using a regex pattern

1 Like

For future reference, the Equals To is not string comparison after all, but rather field comparison, so you can’t compare to “true”. Sorry about that :slight_smile:

2 Likes