24
Views
16
Comments
Validation when storing the value
Question

Hello everyone, I ask for help


It is required to set up validation when storing the value:

Screen form

Allowed characters in the 'Step numbers' and 'Priorities' fields: integer, comma, colon (spaces can be allowed, but they will need to be removed using trim, replace)


.PNG

Hi Kenny,

You can use Regex action for validation.

Thanks,

Samiksha

Rank: #14817

Thank you very much, can you help with pattern for this validation, i can't find in https://regex101.com/?

Rank: #14817

I created a pattern for whole numbers, please help me add a pattern for commas, and colons. Maybe I should use Builtin functions ?

My next steps:

1. Allowed characters in the 'Step numbers' and 'Priorities' fields: integer, comma, colon (spaces can be allowed, but they will need to be removed using trim, replace)

2. The number of characters in the 'Step numbers' field and the number of characters in the 'Priorities' field in one record must match

3. The colon can be written only at the very end

4. Correct format: '2,3,4' or '1,2:' etc.

2.PNG

Hi kennyS

try this in regex :

(?=^[\d]*)(1|,|:)*(2|,|:)*(3|,|:)*(4|,|:)*(5|,|:)*(6|,|:)*(7|,|:)*(8|,|:)*(9|,|:)*(0|,|:)*$

you can validate it on : https://regexr.com/

Hope this work

Thanks


It is working according to 'Step numbers' and 'Priorities' and also accept [, :].

Let me know if it's work for you


mvp_badge
MVP
Rank: #51

Hi Kenny,

Outsystems allows you to use both client side and server side validations. Depends upon your need you can use any or both of them . 

For your specific case you can use some javascript based validation using regex to check your input or even can mask the input fields to allow only certain values . Check the forge for already available components for masking.


Regards,

-PJ-

Rank: #14817

Thank you so much! Now i can't find pattern (js script for my validation). I browse regex101.com ,but i can't find. Can you help me with this problem?


Hi Kennys,


I would like to suggest you to give a try this forge component. It is easy and fulfill your requiremen.

https://www.outsystems.com/forge/component-overview/6574/client-side-custom-regex-regular-expression-validations 


Thanks,

Sanjay

Hi Kenny,

 

You can use the regex_search server action of Text extension.


Using this you can add client side and server side validation.

Please let me know if this helps.

Rank: #14817

I can't find regex_search. I founded regex_check. Can I use this? Thx

.PNG

Rank: #68

Hi Kenny,


You can do it with Regex but for this situation in specific, I think you have an easier way.

You want to validate if it is a number, no matter the spaces the user inserts or if he uses a comma or a colon, right?


Assuming the value is the input the user inserts, this expression will 1) remove spaces 2) replace ";" by "." 3) replace "," by "." and 4) validate if it is a number.

The good thing is this works both client side and server side, you can place it in your if.


Hope it helps.


Cheers,

João

Rank: #14817

Hi! It is required that the user can enter data in the format '2,3,4' or '1,2:' etc.


In fact, all the steps that I have to provide:

1. Allowed characters in the 'Step numbers' and 'Priorities' fields: integer, comma, colon (spaces can be allowed, but they will need to be removed using trim, replace)

2. The number of characters in the 'Step numbers' field and the number of characters in the 'Priorities' field in one record must match

3. The colon can be written only at the very end

4. Correct format: '2,3,4' or '1,2:' etc.

Rank: #68

Hi Kenny,


You can use Regex for that (the component Regex How To shows you how to use it both server side and client side).

If you pass it a string without spaces Replace(value, " ", ""), then you just need to see if the pattern \d+(?:,\d+(;){0,1})*$ exists.


On Server side, it would be something like this using Regex_Search action from Text extension:



And then it is valid if the pattern is found:



On Client side, you would need Javascript but to not make this answer too long, the component shows the Javascript to execute the same thing on the client side.


Hope it helps.


Cheers,

João

Rank: #14817

what is the value object? I have an error on it(unknown object)

Rank: #68

Hi KennyS,


Your value of the object should be the variable of the input you want to validate, in my example below Var1:



João