Validate metadata value is integer


#1

**Matrix Version:5.3.4.0

Is there any way to validate a metadata value is integer? I tried the following but it always give me zero:

%asset_metadata_height^preg_match:/^\d+$/%
%asset_metadata_height^preg_match:/^\[0-9]+$/%

I read in the manual that preg_match:<regex> is used in conjuction with the Regular Expression asset. I am not sure how the two connects.

Cheers,


(Marcus Fong) #2

What the manual page says is that you define the regular expression in a Regular Expression asset, then call the preg_match keyword with the asset ID of that Regular Expression asset.

So instead of:

%asset_metadata_height^preg_match:/^\d+$/%

you would create a Regular Expression asset, set the asset’s regular expression to be /^\d+$/ and then call the keyword like this:

%asset_metadata_height^preg_match:<assetid>%

replacing <assetid> with the actual asset ID of your Regular Expression asset. Does that make more sense?


#3

Awesome, that works! Thanks @mfong.