Is there any function which tells the type of variable?

Is there any function which tells the type of variable?

  

Is there any function which tells the type of variable?

OutSystems is a STRONGED TYPED language.
All variables must have its type defined.
This means that you, as a programer, always knows the type of a variable.
So, I don't know any function that return the type of a variable (in system actions), and never had the need to one :)

Cheers,
Eduardo Jauch 

Hey Lovish, I would love to hear about your use case! Can you tell why do you need to know the type of a variable?

Pedro Cardoso wrote:

Hey Lovish, I would love to hear about your use case! Can you tell why do you need to know the type of a variable?


Because i want to perform the built in validation at server side even if validation is " Client and Server"

Lovish Goyal wrote:

Pedro Cardoso wrote:

Hey Lovish, I would love to hear about your use case! Can you tell why do you need to know the type of a variable?


Because i want to perform the built in validation at server side even if validation is " Client and Server"

i have doubt , if our validation is client and server side can we check the built in validation at server side again? if you know please let me also know


Hi Lovish,

At server side, you know the type of variable. You know if it is text, or date, or currency.

Because it wad you that defined the variable type.

At server side you will check if the values are in the range you expect. If not, you will mark the input valid as false. In the end, you will check the form and will decide if can or cannot do the action.

Cheers

Eduardo Jauch

Answering your last question...

The Client & Side validation perform only two verifications. It see if what the user typed can be converted to the variable's data type associated with the input. And it verify if a mandatory field has something in it.

If both tests pass for all the inputs in the form (page, really), than the action is called and you can perform, server side, personalized validations.

So, yes, you can perform validations server side even if you use Client & Server validation (than the "Server" in Client & Server).

Cheers

Eduardo Jauch

Seems that Eduardo Jauch already provide the answers. Is that OK Lovish?

Kind of an old thread here but I have the same issue. I have an input field to where I only want to accept integers, however input fields can accept "Text", "Number", "Email" and "Search". This is not very strongly typed... 

I set it to number, of course, but I assume that means decimals too.

So how do I validate if the inputted thing is an integer? 

Mariano Picco wrote:

Kind of an old thread here but I have the same issue. I have an input field to where I only want to accept integers, however input fields can accept "Text", "Number", "Email" and "Search". This is not very strongly typed... 

I set it to number, of course, but I assume that means decimals too.

So how do I validate if the inputted thing is an integer? 

Hello Mariano Picco,

If you define the input type as number, the user normally wont be able to insert nothing besides numbers in that input.


Of course there are ways ( in client side ) to put text in there... Using the inspector, injecting, etc.

So, normally you always have to check that on server side so that you are sure that the user really sent in the input only numbers.


So, to do that you put type: "Number" and set the validation to "Client and Server"


Then, when the user submits the info just use the function "TextToIntegerValidate" for example on your variable that will return TRUE if that variable only has numbers on it.


Cheers


Hi,


If you really want to validate the input with for example the variable 'type', your best bet is use a Mask or some regex and use a text input field.

Mask for client side validation and regex for serverside validation.(or both)

It will help you validate decimal fields or specific types of inputs + they are commonly used around the web. You can easly find some rules that will apply to you.

Example of a mask component :
https://www.outsystems.com/forge/component/274/input-masks/

For regex feature, you can find more information here:

https://success.outsystems.com/Documentation/Development_FAQs/How_to_use_regular_expressions

Greeting,
Niels F.