Subscribe rss
Blog categories
All | Backendless features
Feature 54: Validating data object properties with regular expressions
March 2, 2015 by markpiller

When saving or updating a data object in a the persistent storage it is often needed to make sure a property follows a particular data format. For instance, properties like email address, a US phone number, a bank account number, a URL and many others may be validated with regex (a regular expression). Backendless makes it very easy to do that. For any property, or a column to be precise, developer can specify a regex which will be used to validate incoming values. The values are validated when an object is saved or updated. If the validation fails, so does the API operation. Consider the following example:

The table below has the SSN property which will store US social security numbers. To validate the values stored in the table, I will use a regular expression.

Notice the validator in the Custom regex field:

The regular expression validates any US social security number in the XXX-XX-XXXX format. Once the column is saved, try entering a value for the column using console or the API. Saving or updating any value which does not follow the format above would result in an error.

Share this post
Tweet about this on TwitterShare on FacebookGoogle+