Created
February 22, 2017 22:30
-
-
Save olivermt/39baac6bb207343d139edeba7ed7375d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_version(cs = %{ | |
valid?: true, | |
changes: %{definition: new_def, version: client_version}, | |
data: %{definition: old_def, version: db_version}}) | |
when client_version > db_version do | |
case Map.equals(new_def, old_def) do | |
true -> | |
put_change(cs, :version, version+1) | |
false -> | |
add_error(cs, :definition, "definition_out_of_sync") | |
end | |
end | |
def validate_version(c = %{data: %{version: version}}), do: put_change(c, :version, version+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment