refactor buyer and insured and add more policy types
All checks were successful
Build and Publish / build-release (push) Successful in 1m38s
All checks were successful
Build and Publish / build-release (push) Successful in 1m38s
This commit is contained in:
@@ -11,21 +11,52 @@ defmodule PolicyService.Aggregates.CarPolicyApplication do
|
||||
"make" => make,
|
||||
"model" => model,
|
||||
"year" => year,
|
||||
"car_value" => car_value,
|
||||
"use_type" => use_type,
|
||||
"car_type" => car_type,
|
||||
"rc_limits" => _rc_limits,
|
||||
"market_value" => market_value,
|
||||
"requested_value" => requested_value
|
||||
})
|
||||
when is_binary(plate) and is_binary(make) and is_binary(model) and
|
||||
is_integer(year) and
|
||||
is_number(market_value) and market_value > 0 and
|
||||
is_number(requested_value) and requested_value > 0 and
|
||||
is_binary(use_type) and byte_size(use_type) > 0 and
|
||||
is_binary(car_type) and byte_size(car_type) > 0 do
|
||||
cond do
|
||||
year < 1886 or year > Date.utc_today().year + 1 -> {:error, :invalid_car_year}
|
||||
use_type not in @valid_use_types -> {:error, :invalid_use_type}
|
||||
car_type not in @valid_car_types -> {:error, :invalid_car_type}
|
||||
byte_size(plate) == 0 -> {:error, :missing_plate}
|
||||
true -> :ok
|
||||
end
|
||||
end
|
||||
|
||||
def validate_details(%{
|
||||
"plate" => plate,
|
||||
"make" => make,
|
||||
"model" => model,
|
||||
"year" => year,
|
||||
"use_type" => use_type,
|
||||
"car_type" => car_type,
|
||||
"chassis_number" => chassis,
|
||||
"engine_number" => engine
|
||||
"engine_number" => engine,
|
||||
"rc_limits" => _rc_limits,
|
||||
"market_value" => market_value,
|
||||
"requested_value" => requested_value
|
||||
})
|
||||
when is_binary(plate) and is_binary(make) and is_binary(model) and
|
||||
is_integer(year) and is_number(car_value) and car_value > 0 and
|
||||
is_integer(year) and
|
||||
is_number(market_value) and market_value > 0 and
|
||||
is_number(requested_value) and requested_value > 0 and
|
||||
is_binary(use_type) and byte_size(use_type) > 0 and
|
||||
is_binary(car_type) and byte_size(car_type) > 0 and
|
||||
is_binary(chassis) and is_binary(engine) do
|
||||
cond do
|
||||
year < 1886 or year > Date.utc_today().year + 1 -> {:error, :invalid_car_year}
|
||||
use_type not in @valid_use_types -> {:error, :invalid_use_type}
|
||||
car_type not in @valid_car_types -> {:error, :invalid_car_type}
|
||||
byte_size(chassis) == 0 -> {:error, :missing_chassis_number}
|
||||
byte_size(engine) == 0 -> {:error, :missing_engine_number}
|
||||
byte_size(plate) == 0 -> {:error, :missing_plate}
|
||||
true -> :ok
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user