FixAlchemy.Engine.Validation (FIXAlchemy v0.3.0)

View Source

Session-level checks an acceptor applies to every inbound message.

validate/3 reports the first problem it finds, in the order the session protocol prescribes: BeginString, MsgType, tag validity, required tags, comp ids, then SendingTime.

Checks run only when a session sets validate_inbound: true.

Outcomes

  • :ok - the message may be processed
  • {:reject, problem} - answer with a Reject (35=3) built from problem, and end the session afterwards when problem.disconnect? is true
  • {:logout, text} - answer with a Logout carrying text and end the session; the counterparty is speaking a different protocol version, so a Reject would not be understood

problem.reason is the SessionRejectReason (tag 373) to send, and problem.ref_tag the RefTagID (tag 371) when one tag is at fault.

Summary

Functions

Check one inbound message.

Types

outcome()

@type outcome() :: :ok | {:reject, problem()} | {:logout, binary()}

problem()

@type problem() :: %{
  reason: non_neg_integer(),
  text: binary(),
  ref_tag: pos_integer() | nil,
  disconnect?: boolean()
}

session()

@type session() :: %{
  :fix_version => binary(),
  :sender_comp_id => binary(),
  :target_comp_id => binary(),
  :spec_modules => [module()],
  optional(:max_latency) => pos_integer()
}

Functions

validate(session, msg_type, fields)

@spec validate(session(), binary() | nil, [{binary(), binary()}]) :: outcome()

Check one inbound message.

fields is the message as FixAlchemy.Parser.split_fields/1 returns it — string tag/value pairs in wire order, including the header and trailer.