Rules For Robust Application

In order for an application to be future proof, there are some basic rules that should be followed.

1. Use value-as-cents for monetary values

Lets say that a customer is trying to insure his digital camera. One of the pieces of information that must be collected is the value of the camera.

The customer knows the value of this item in EUR. In the KASKO platform monetary values are used as cents.

This means that if the customer types in 1200.34 EUR, it must be converted to 120034 when sent to the KASKO API.

For this to happen automatically, form-input-monetary component can be used.

2. Field names must follow common convention

  1. Field names must be lowercased;

  2. Field names must use underscores;

  3. Some field names are not acceptable (see table below);

Examples:

Good:
item_value
item_name

Bad:
itemValue
Item_name
Item_Name

Wrong field names:

3. Dates & Times

Datetime values MUST always be in UTC. Storing times in UTC has HUGE advantages compared to storing them in local timezone.

When API needs to accept a date/time value, it must always accept the date/time values formatted as ISO 8601 string. iso_date validation rule can be used for this.

When using date input components in the frontend (i.e. form-datepicker), the custom input is automatically converted to an ISO 8601 date if iso_date validation rule has been set.

4. Percentages

When dealing with percentages, use decimal values. For example, if you need to store 15%, then you should store it as decimal 0.15.

Last updated