Draw an ASCII Rectangle Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height.

Or, if your language supports it, the two integers can be given as separate inputs.

Assume the width and height will never be less than 3, and they will always be given.

Example Outputs:

[3, 3]

|-|
| |
|-|


[5, 8]

|---|
|   |
|   |
|   |
|   |
|   |
|   |
|---|


[10, 3]

|--------|
|        |
|--------|


This is code-golf, so the answer with the lowest amount of bytes wins.
Jelly, 14 bytes

,þ%,ỊḄị“-|| ”Y


Try it online! or verify all test cases.

How it works

,þ%,ỊḄị“-|| ”Y  Main link. Left argument: w. Right argument: h

,þ              Pair table; yield a 2D array of all pairs [i, j] such that
                1 ≤ i ≤ w and 1 ≤ j ≤ h.
   ,            Pair; yield [w, h].
  %             Take the remainder of the element-wise division of each [i, j]
                by [w, h]. This replaces the highest coordinates with zeroes.
    Ị           Insignificant; map 0 and 1 to 1, all other coordinates to 0.
     Ḅ          Unbinary; convert each pair from base 2 to integer.
                  [0, 0] -&gt; 0 (area)
                  [0, 1] -&gt; 1 (top or bottom edge)
                  [1, 0] -&gt; 2 (left or right edge)
                  [1, 1] -&gt; 3 (vertex)
       “-|| ”   Yield that string. Indices are 1-based and modular in Jelly, so the
                indices of the characters in this string are 1, 2, 3, and 0.
      ị         At-index; replace the integers by the correspoding characters.
             Y  Join, separating by linefeeds.