View Source Teiserver.Helpers.SchemaHelper (Teiserver v0.0.1)

A set of functions for helping with schema files

Summary

Functions

Given params and a pair of fields, ensures the lower value of the two is assigned to the first field and the higher value to the second.

Given a list of fields and a list of patterns, will apply Regex.replace for every pattern to each field.

Applied Enum.uniq to one or more fields in the params

Functions

Link to this function

min_and_max(params, list)

View Source
@spec min_and_max(map(), [atom()]) :: map()

Given params and a pair of fields, ensures the lower value of the two is assigned to the first field and the higher value to the second.

%{f1: 5, f2: 3} |> min_and_max(~w(f1 f2))

%{f1: 3, f2: 5}

Link to this function

remove_characters(params, names, patterns)

View Source
@spec remove_characters(map(), list(), list()) :: map()

Given a list of fields and a list of patterns, will apply Regex.replace for every pattern to each field.

Link to this function

trim_strings(params, fields)

View Source
@spec trim_strings(map(), list() | atom()) :: map()
Link to this function

uniq_lists(params, names)

View Source
@spec uniq_lists(map(), list()) :: map()

Applied Enum.uniq to one or more fields in the params