Ni particle in complex sentence


暴力に正当な理由があるとすれば、自分や誰かを危険から守るためだけだ。 in this sentence why did we use に particle
after 暴力. how does it come here, explain the grammar




That is a complex sentence, but actually, only the first part is relevant.

Maybe the size of the sentence is a little distracting.

> 「暴力に正当な理由がある」
>
> 「ぼうりょくにせいとうなりゆうがある」
>
> There is a justified reason for the violence.

Basically, に is there because of ある。

I googled 理由がある。

> A book on Amazon...
>
> 不愉快なことには理由がある
>
> A book defending jazz...
>
> すごいジャズには理由（ワケ）がある
>
> An page about energy bars...
>
> その栄養には、理由がある。

It's kind of like English.

"There's a reason to..." or "There's a reason in..."

You can read more about に and the verbs that like it at [this
question.](https://japanese.stackexchange.com/questions/2197/%E3%81%AB-
and-%E3%81%A7-revisited)

