[Question]
  [
Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. **Additionally, the source code for your solution must be rectangular**.
A string is rectangular if it meets all of the following conditions:
1. The first line and the last line contain no spaces.
2. The first and last character of each line is not a space.
3. All lines have the same number of characters.
For example, the following text is rectangular:
```
abcd
e fg
hijk
```
This text, however, is not rectangular (requirement #3):
```
1234
567
8900
```
## Test Cases
Truthy:
```
sdghajksfg
```
```
asdf
jkl;
```
```
qwerty
u i op
zxcvbn
```
```
1234
5  6
7890
```
```
abcd
e fg
hijk
```
Falsey:
```
a b c
```
```
123
456
7 9
```
```
12
345
```
```
qwerty
 uiop
zxcvnm
```
```
1234
567
8900
```
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest solution in bytes wins.
  
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~127~~ ~~125~~ ~~124~~ 118 bytes
* Saved two bytes by golfing `r*=!e&(!t|t==c);` to `r>>=e||t&&t-c;`. *(This golf was the inspiration for my recent C tips answer [Inverse flag update](https://codegolf.stackexchange.com/a/164010/73111).)*
* Saved a byte by golfing `*(_-2)` to `_[~1]`.
* Saved six bytes by golfing `*_++-10||(...)` to `*_++<11?...:0` and utilizing the placeholder zero `...:0` (which is not used constructively) to golf the `c++` increment. Those golfs allowed some further loop reshuffling.
* When one can use multiple falsey values, [114 bytes](https://tio.run/##hZDrbsIwDIV/b0@RVVqV9CK1tIWxEvEgyxS1ISmFYVgadiPs1UurDWlMWif5hyV/xz4@IqyEaFsdyEAEJudYLAvtcXJQW401NVTQKPd4V74/i@O59umNcV3cDQJJrPX4LEksf/iMH/vGmlAEgkoa3QvfJx4Pk5G1WNKY5NpS2QGu2zH5sd0UNWByuL7a6RqMwo5Bc3S7YOAEiGOnWVTLYrVuVOUQkv9FFc1CMVitn/Ih6vlVavPOYI9qtN0x@HgTLyUMKeJRkjLIEBozmNxNo0EPpeh6iVTFYFmv1t/s3jTYcX7K1KUMlUhc7lW/PTBIs94Bmg6DDJI0G0LOCaB9fQ4ANv8c7wMYTxh073/9f2xP) could be possible.
```
r,e,c,t;_(char*_){for(r=1,t=c=0;*_;*_++<11?r*=(t||(t=c,!e))&*_>32&_[~1]>32&t==c,c=e=0:c++)*_-32||(e=1);r>>=e||t&&t-c;}
```
[Try it online!](https://tio.run/##hZDrTsMwDIV/w1OESlRJm0pruwsjpHsQgqIuS7puzBtpxm0dr15awSSGRJH8w5K/Yx8fFRVKNY2lmirqmMRqmdtAkoPZWmx5TB1XfMAC2VYY3sXxzAYcu7rG7YBeaUL8QGZp4sv7j/ihaxxvB4prPrhVYUgCGaVJi2seE2azjOu6dr7vIsWOzSYvAZPD5cXOluAM9hyaoeuFAI8iib1qUSzz1boyhUcI@4vKq4URsFo/sj7q6UVb9yZgj0q03Ql4f1XPc@hTxEk6FDBCaCxgcjMd9HqYq7bXyBQCluVq/c3uXYU976fMnMvQHKnzvea3BwHDUecATftBAelw1IecEkD78hQAbP453gUwngho3//6/9h8Ag "C (gcc) – Try It Online")
*[Source layout achieving a taller rectangle.](https://tio.run/##hZDrboJAEIV/l6fYkpTscokiqLV09UG6zQaWXUTraJelN9FXp5jWpDYpTebHJPOdmTNHBIUQbat96QvfJByLZapdTvZqq7GmoW@ooMPE5V153r0VhgvtUmyaBncT/1oS4rh8Ho0c/nAMH0@Nod3AElTS4Z3wPOLyIBp1vKQhSfR8TmXTGMcxgUgOg0G7SUvAZG9d7XQJRmHboAW6yRnYPuLYrvJima7WlSpsQpK/qLTKFYPV@inpo55fpTbvDGpUou2OwcebeMmgTxGOopjBGKEJg@ntbNjrIRNdL5EqGCzL1fqbrU2FbfunTF3KUIbE5V712wODeHxygGb9IIMoHvch5wRQXZ4DgM0/x08BTKYMuve//j@0nw)*
# Explanation
*The following explains the 124 bytes long version.*
```
r,e,c,t;_(char*_){     // `r` is the boolean result flag, `e` a boolean flag if the current line contains
                       //  a space, `t` the first line's width, `c` the current line's current width
 for(r=1,t=c=0;*_;c++) // initialize, loop through entire string
  *_-32||              // if the current char is a space,
   (e=1),              //  the current line contains a space
  *_++-10||            // if the current char is a newline (char pointer `_` now incremented)
   (r*=(t||(t=c,!e))   // if t is not yet set, the current line is the first line; set it
                       //  to this line's length, check that no spaces where found
    &*_>32             // the next line's first char should not be a space
    &_[~1]>32          // this line's last char should not have been a space
    &t==c,c=~0,e=0);   // the line lengths should match, reset `c` and `e` to zero
                       //  (`~0 == -1`, countering the loop's increment of `c`)
 r>>=e||t&&t-c;}       // return boolean flag, check that the last line does not contain spaces,
                       //  there was either no newline or line lengths match
                       //  (here) equivalent to `r*=!e&(!t|t==c)`
```
[Try it online!](https://tio.run/##hVPbcpswEH1uvmLjmbpg44kd59IMQ/ohpQOyWEAxlhwh4lzc/Lq7ku04xAnlCdDu2XNZ8VHB@WajAwx4YMLE4yXTg8R/AfucnUGqUxA1mBJhplSFTILGuqkM5BUrAkgxBfZ2ZP@ByF05b7RGaaASkj6UNEzI@gQ@f2gSwdRLxpEwTeoQcqHrbf@PGlYiMyWd8fQInU73n67qBHKlPR1NAhPxaBwOkpAPh74dIqQwglXimcZUSi0JS6umKIGahUaojRayIJaDZDQ9X6@PWH4QZ@2y/uy5W30eRhM/ONb3pSn7bjd2OBxNxu3BXWMlrhyWCw6WSkiDGtIkBalWJJdrXFAHZr6jpgeRZ9Zrj4wJTtH3D@gWTioDT2igRhMc092twSGV0BaCMF2hGkVN1LnLqUJZ2Bh5iXxOJ8zQ0K16irhEiiBXjcwcZH@Q3E7PP0JaDhIf36Lf8nHy61I1VeZkzPCdqwSV/H6d/GmhOah3zNgnKCV7oL1HlG0wE5F9PHodBxiN/fDAy/m01VjvcRbMcFJMt4bMsuvLZOauDVnzjFp1ueelr2OIIhhNUvKMjKFwaT@3s2h9ifdbxKByC08569vbCNdr0@@bEQ//HvA0mkbL1m1tReFg2S5dyBRuV2K3p7uYgs64XYQrVgMK@27T3a@o0m1/nDGd6i2YD3jfiAdWWYlkWUorfIp979SsbQx@ulkQN89/Ofm2JG9M7vUM/ILvWSx7ASRer86Kkt3N67zo@X74VRWrszyWd/Mq7Kq6X6E2T7FsQIBaxvL5kT/MZFfH5Hx6EctLgKtYXv@8GXdymHF6pxtQxLIUd/NdbWNqr9d735a322AGvI2bf@QQy4tLywBuugtjOb247CrZOwCN2BsgF/8Zbg24uo4lyd/q/7v5Bw "C (gcc) – Try It Online")
[Answer]
# Java 10, ~~214~~ ~~176~~ ~~169~~ ~~152~~ ~~144~~ 139 bytes
```
s->{String[]a=s.split("\n")
;int r=1,i=0,R=a.length;for
(;i<R;i++)if(i<1|i>R-2?a[i]
.contains(" "):a[i].trim( )
!=a[i])r=0;return-r<0;}////
```
-5 bytes thanks to *@Neil*.
Uses `String[]a` instead of `var a`; `return-r<0;` instead of `return r>0;`; and added a comment `//` at the very end, so there aren't spaces on the first and last rows.
Note that this rectangle is shorter than a single-line input, because `int r=1,...;` should be replaced with `int[]v{1,...};`, and all uses of the integers would then becomes `v[n]` (where *n* is the index of the variable in the array `v`).
[Try it online.](https://tio.run/##rVTPU@IwFL73r3jmlAxSQFF3LXVv3vQAe7Me0jQtKSHpJimKyt/OBpTZmR0lOEOmObzme@97v@ar6YJ262K2ZpJaC3dUqNcIQCjHTUkZh/uNCZBrLTlVwPDEGaEqsCTxDyt//WcddYLBPShIYW27N6/vqIdHmtrYNlI4jDKFSJT4yGDSwalI@6fjlMaSq8pNk1KbCCdiNE5Ep0NEicVo8CZuxt2zX/RBPEYx08r55CxGgMj15l/sKeYYSHSSbkxi0n5iuGuN6ppRP1n1/FlvkmzaXPrsPpJcaFHA3IfCuxyBkvciez34bVo3XV5vzcnSOj6PdevixiOdVFjFDCOas8IX09mCvjiIQ1kFQVNRzxDZdvJrOltUU1rPbFkFodQWZZC0nskkGOnPEzduGYzVggDdBGEvz2yRqyDp4Ox8GIx1AXAZBF39@NkPd@v4c9yt0S2VlgfW6LBqL68gCPLFHlAt5MAOGEGY7nx4caz9gVboBg7aHzU/0v58q6O7gU50a7waMl1wEM5yWe4f7ucamKEsUxkiQf49Mhn03SOjQd9/MpshyP4T2qD3HiH@mN0qWq3/Ag)
**Explanation:**
```
s->{                        // Method with String parameter and boolean return-type
  String[]a=s.split("\n");  //  Input split by new-lines
  int r=1,                  //  Result-integer, starting at 1
      i=0,                  //  Index `i`, starting at 0
      R=a.length;           //  Amount of rows `R`
  for(;i<R;i++)             //  Loop `i` over the rows
    if(i<1                  //   If it's the first row,
       |i>R-2?              //   or the last row:
        a[i].contains(" ")  //   And the current row contains a space
       :a[i].trim()!=a[i])  //   Or either column of the current row contains a space
      r=0;                  //    Set the result `r` to 0
   return-r<0;}             //  Return whether `r` is still 1
////                        // Comment to comply to the rules of the challenge
```
Here is the same base program with spaces (**~~128~~ 126 bytes**):
```
s->{var a=s.split("\n");int r=1,i=0,R=a.length;for(;i<R;i++)if(i<1|i>R-2?a[i].contains(" "):a[i].trim()!=a[i])r=0;return r>0;}
```
-2 bytes thanks to *@Neil*.
[Try it online.](https://tio.run/##rVTPU@IwGL3zV3zm1AxSQFF3DWVv3vQAe7Me0jQtKSHpJimKyt/OBhbG2XEkOEOmPXzty/ve92NeRRe0U@WzNZPUWrinQr21AIRy3BSUcXjYhACZ1pJTBSyaOCNUCRYT/2PlX/9YR51g8AAKEljbzuhtQQ3QxMa2lsJFKFUIE08KJumfi6R3Pk5oLLkq3ZQU2kREDMdEtNtYFJEY9t/FaNy5@EUfxVPMtHJelY0QIHy7/eQVzCN8lmwCbJIeMdw1RoEZ9chqTVpeUd1k0ivaCVtokcPcs@zUPz4Bxf8K63bht2ncdHm7DSdL6/g81o2La490UkUqZhGiGct9Ee0t6IuDOBRlEDQV1Qzhbfe@TmfzckqrmS3KIJTavAgmrWaSBJn@PHPjlkGuBgToOgh7fWGLTAWT9i8uB0GuK4DrIOjmx89euFunn@N@je6otDywRsdVe30DQZAv9ohqIQN2xAjC6S4HV6faH2iEruGo/VHzE@3Ptzq6H@hEN8Y7INM5B@Esl8Xh4W58b@8vH96XojRVKcLB/Af8MXj3gIEG7344bIog/c9jIaz6kwt3zNC7cNef3exWrdX6Lw)
[Answer]
# T-SQL, ~~237~~ 207 bytes
```
SELECT(SELECT(IIF(max(len(v))=min(len(v)),1,0)*IIF(SUM(len(v+'x')-len
(trim(v))-1)=0,1,0))FROM t)*(SELECT(IIF(SUM(charindex(' ',v))=0,1,0))
FROM[t]WHERE[i]IN(SELECT(min(i))FROM[t]UNION(SELECT(max(i))FROM[t])))
```
Outputs 1 for rectangular, 0 otherwise. I had to use tons of extra parens and brackets to eliminate spaces, I'm sure there is vast room for improvement.
**Explanation**:
[Per our allowed I/O options](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/5341#5341) and clarification in the question comments, input is taken as separate rows in a pre-existing table **t**. Because data in SQL is inherently unordered, that table includes a "row number" identity field **i**:
```
CREATE TABLE t (i INT IDENTITY(1,1), v VARCHAR(999))
```
Basically my SQL performs 3 subqueries, each of which returns `0` or `1` based on the 3 criteria of "rectangular" code. Those 3 values are multiplied together, only returning `1` for code that satisfies all 3.
**EDIT**: Combined criteria 2 and 3 into the same SELECT to save space
```
SELECT(
SELECT(IIF(max(len(v))=min(len(v)),1,0)                  --All rows same length
      *IIF(SUM(len(v+'x')-len(trim(v))-1)=0,1,0))FROM t) --no leading or trailing spaces
*(SELECT(IIF(SUM(charindex(' ',v))=0,1,0))               --No spaces at all in
FROM[t]WHERE[i]IN(SELECT(min(i))FROM[t]                  --   first row or
            UNION(SELECT(max(i))FROM[t])))               --   last row
```
The `TRIM(v)` function is only supported by SQL 2017 and above. Earlier versions would need `LTRIM(RTRIM(v))`, which would require rebalancing the rows.
One random note: the `LEN()` function in SQL ignores trailing spaces, so `LEN('foo ') = 3`. To get a "true" length you have to tack a character on to the end then subtract one :P
[Answer]
# C++, ~~199~~ ~~183~~ ~~181~~ 175 bytes
This template function accepts lines as a collection of strings (which may be wide strings), passed as a pair of iterators.
```
#include<algorithm>//
template<class I>bool
f(I a,I b){return!~+(
*a+b[-1]).find(' ')&&
std::all_of(a,b,[&a](
auto&s){return' '+-s.
back()&&s[0]-' '&&a->
size()==s.size();});}
```
Thanks are due to user [Erroneous](/users/42487) for reminding me of the `back()` member of `std::string` and for pointing out that `npos+1` is zero.
## Ungolfed equivalent
The only real golfing is to concatenate the first and last lines so we can perform a single `find` for spaces in those.
```
#include <algorithm>
template<class It>
bool f(It a, It b)
{
    return (*a+b[-1]).find(' ') == a->npos
        && std::all_of(a, b,
                       [=](auto s) {
                           return s.back() != ' '
                               && s.front() != ' '
                               && s.size() == a->size(); });
}
```
# Test program
```
#include <iostream>
#include <string>
#include <vector>
int expect(const std::vector<std::string>& v, bool expected)
{
    bool actual = f(v.begin(), v.end());
    if (actual == expected) return 0;
    std::cerr << "FAILED " << (expected ? "truthy" : "falsey") << " test\n";
    for (auto const& e: v)
        std::cerr << "  |" << e << "|\n";
    return 1;
}
int expect_true(const std::vector<std::string>& v) { return expect(v, true); }
int expect_false(const std::vector<std::string>& v) { return expect(v, false); }
```
```
int main()
{
    return
        // tests from the question
        + expect_true({"sdghajksfg"})
        + expect_true({"asdf", "jkl;",})
        + expect_true({"qwerty", "u i op", "zxcvbn",})
        + expect_true({"1234", "5  6", "7890",})
        + expect_true({"abcd", "e fg", "hijk",})
        + expect_false({"a b c",})
        + expect_false({"123", "456", "7 9",})
        + expect_false({"12", "345",})
        + expect_false({"qwerty", " uiop", "zxcvnm",})
        + expect_false({"1234", "567", "8900",})
        // extra tests for leading and trailing space
        + expect_false({"123", " 56", "789"})
        + expect_false({"123", "45 ", "789"})
        // the function source
        + expect_true({"#include<algorithm>//",
                       "template<class I>bool",
                       "f(I a,I b){return!~+(",
                       "*a+b[-1]).find(' ')&&",
                       "std::all_of(a,b,[&a](",
                       "auto&s){return' '+-s.",
                       "back()&&s[0]-' '&&a->",
                       "size()==s.size();});}",})
        ;
}
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 85 bytes
```
x=>(x=x.split`\n`).some(s=>s.length-x[0].length|s.trim()!=s)<!/\s/.test(x[0]+x.pop())
```
[Try it online!](https://tio.run/##jZBdT8IwFIbv@RWHq7UhFJQNJDD@iDNhH93WrWvHTsFq/O9T1DRGbcLdeZPnPXnzNOklxXwQvZkrXfCxjEcbH4iNLcNeCnNM1JEy1B0nGB@QSa4qU8/t4/Lp@35DZgbRETqNke6niwQXzHA05MrMLOt1Tygdc61QS86krkhJJgABFlWdNi2WVUDpbvIXSLEoExXA7BqaVu483OmZD@bFkWcQoHsXX21@yZSnene/Ch0ZAaxd2Dxsl75dWV44jkNZuVCLpv0s/deCDHL/DPcjjH6MgK234aBVGN0mBs7ilxfV3eRlvQEXPrR8eRnfAQ "JavaScript (Node.js) – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 82 bytes
```
lambda*s:len(set(map(len,s)))<2<'!'<=min(tuple(s[0]+s[-1])+zip(*s)[0]+zip(*s)[-1])
```
[Try it online!](https://tio.run/##rZBLcoMwEET3c4rJShKOUzYGO3bgJMYLPsKIj5AZkcS@PBFUOblAdt1T3a@qx9xt1Wt/KuNkatMuK1KPTq3UnKTlXWq4068khIj8iL2wKO6U5nY0reR03lxWdF5vL2L1UIZ7JObLU873yUqyhDEOjDEqrlVaN1ReAVIqSqib9gPg9iUHe4cRFfYGHt/5Z6YBtv4ugBBxD4f348YVsrwAia5bqbpxHjPMlxgEoQvhcTYIuyD8ReKoeoMLUndP5P4ADuiI/7/WbXwj0yrLWaITzQRA2Q9oUWlcHnFCMyhtseSe/UsyIWD6AQ "Python 2 – Try It Online")
Invoke as `f("abcd", "e fg", "hijk")`.
[Answer]
# [Haskell](https://www.haskell.org/), ~~106~~ ~~102~~ ~~98~~ ~~110~~ ~~109~~ 102 bytes
```
(\a->all(==[])a||and(e((1<$)<$>a):map(all(>='!').($a))[head,last,map$last,map$head]));e(a:s)=all(==a)s
```
Thanks to @nimi and @Laikoni for a byte each!
[Try it online!](https://tio.run/##vY9NDoIwEIX3nmIkJM4kSOJWLTfwBJTFiEUbS60Uf@PZrajowgO4ei/ve5mX2bDfKmNCJWRAyeOMjUEh8oL4dmO7QoU4mcc0jzOmac0On4VMjIYjSjFmonyjeJUY9m3S4fhrnnFBNFPIU0/ifZfJh5q1BQFdZwHoGm3btEqNtsoTDAByiBiWUEadTyDan1TTXqSFg945aa/n8mjrH3YADR@4tD1E@Zd3@rVe5Gu9CPeyMrz2YVw69wA "Haskell – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 79 bytes
```
g(x:r)=all((==(0<$x)).(0<$))r&&all(>='!')(x++last(x:r)++(head<$>r)++(last<$>r))
```
[Try it online!](https://tio.run/##tY9BDoIwEEX3nmIkBDqpIRp3SrmBJwAWRRtoLBULaPXyFRrcuHcx@T//TeZnGt5fhVLO1cQeDDKuFCGMkW0aWsRkVkQTRXOesXgdI7GUKt4Pfp9S0gh@ScPM@zn3Ho91XrJdunctlxoYtLw7AemM1AMkUE@jpBY9wgogh4BDBedg8hsI7k9hhlehYZS3rtBve37o9oeNIOELK73AP72wXF@k8G2l@wA "Haskell – Try It Online") Takes input as a list of lines.
The pattern `g(x:r)= ...` binds the first line to `x` and the (possibly empty) list of remaining lines to `r`. Then `all((==(0<$x)).(0<$))r` checks if all lines in `r` have the same length as `x` (Using [this tip](https://codegolf.stackexchange.com/a/146634/56433)). 
If not, then the conjunction `&&` short-circuits and returns `False`, otherwise the right hand side is evaluated. There a string is build which consists of `x` for the first line, `last(x:r)` for the last line of `r` (or the first line again in case `r` is empty) and `(head<$>r)` for the first and `(last<$>r)` for the last character of each line. For this string, `all(>='!')` checks that it does not contain any spaces (we can't use `(>' ')` because of the source code restriction).
[Answer]
# [MATL](https://github.com/lmendo/MATL), 13 bytes
```
ctgF6Lt&()32>
```
Input is an array of strings, in the format `{'abc' 'de'}`.
Output is an array containing only ones, which is [truthy](https://codegolf.stackexchange.com/a/95057/36398), or an array containing at least a zero, which is [falsey](https://codegolf.stackexchange.com/a/95057/36398).
[Try it online!](https://tio.run/##y00syfn/P7kk3c3Mp0RNQ9PYyO7//2r1xKTkFHUdBfVUhbR0EJ2RmZWtXgsA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##VY7NTsMwEITvfoq9UDeXqDQ/pUKCS0FC4tgrEk5sJ05cO8QOJVR99rCkUCU@eHdnNPvtgXk9vMP13cDOhmF4LJUWsFRGKqO8AG1tEwy5L57TV79YBtH6YXicpl4kob7tfNlTcp4aT9oJQiXDgtbbzDKc7GZo5RrNerKfivu2w0t@D4DcGq68siYYTtTxomRV7WRBz@REmeOSAq1qfT/OH0fR@h6VDhTYBpvvr/wzM6N5u45iVBKAFMvmbru67MhyjrMA3Am0VFV9kSGD/D@HRpyMKdj@aThEcTKnQqeuUHOYQdMN/ohE5g8), including truthiness/falsihood test.
### Explanation
```
c       % Implicit input. Convert to char. This concatenates the
        % strings of the input cell array as rows of a rectangular
        % char array, right-padding with spaces as needed
tg      % Duplicate, convert to logical. Gives a logical array with
        % the same size containing true in all its entries
F       % Push false
6L      % Push the array [2, j-1], where j is the imaginary unit.
        % When used as an index, this is interpreted as 2:end-1
t       % Duplicate
&(      % Assignment indexing with 4 inputs: original array, new
        % value, two indexing arrays. This writes false at the inner
        % rectangle (2:end-1)×(2:end-1) of the logical array that
        % initially only contained true. This will be used as a
        % logical index (mask) into the rectangular char array
)       % Reference indexing. This selects the border of the char
        % array. The result is a column vector of chars
32>     % Is each entry greater than 32? (ASCII code for space)
        % Implicit display
```
[Answer]
# JavaScript (ES6), 88 bytes
```
s=>!s.split`\n`.some((s,i,a)=>s[L='length']-a[0][L]|(++i%a[L]>1?/^\s|\s$/:/\s/).test(s))
```
[Try it online!](https://tio.run/##jZDtboJAEEX/@xTTpA27QUEraK2BvoBvADQusMAC7lJntR/x3am2yaZpS@K/ucm5k5tTsyPDbC86PZEq530R9BiEN@hg1wq9jeXWQbXjhOBYjBkNQow2gdVyWerKSiYsmibRJjkR2xZ37HyFsyf3OcZTjLfuoxujSx3NUROktM@URNVyp1UlKcgIwMK8rFjdYFFalK5HfwGGeRFLC@xLqJt2PcC9vPK9fjfkAQSozsSPt@yYyoHq7H7uGdIHWJiwfFhNh3alWW44DkVpQiXq5qv0XwtSyIZnmB@e/2MErAYbBpp7/nVi4CB@eZG7q7wslmDCWcu3l/4T "JavaScript (Node.js) – Try It Online")
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), ~~17~~ 15 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
４［↷Ｋ；｝┐）｛ＳＬ］∑４≡
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjE0JXVGRjNCJXUyMUI3JXVGRjJCJXVGRjFCJXVGRjVEJXUyNTEwJXVGRjA5JXVGRjVCJXVGRjMzJXVGRjJDJXVGRjNEJXUyMjExJXVGRjE0JXUyMjYx,i=JTYwJTYwJTYwJTBBMTIzNDUlMEE2JTIwJTIwJTIwJTBBMyUyMCUyMCUyMDMlMEE4OTEyMyUwQSU2MCU2MCU2MA__,v=2)
Explanation (ASCII-fied for monospace):
```
4[↷K;}┐){SL]∑4=  full program; pushes the input to the stack.
4[   }           repeat 4 times
  ↷                rotate ToS clockwise. This also pads the input with spaces
   K;              take off the last line and put it below the item
      ┐          pop the remaining of the input (the center)
       )         and wrap the rest (the sides) in an array
        {  ]     map over those
         S         split on spaces - should result to one item in the array
          L        and get the length
            ∑    sum those lengths together
             4=  check if equal 4
```
[Answer]
# [Perl 5](https://www.perl.org/), 70 bytes
```
$f||=$_;$l||=y///c;$,||=/^\s|\s$/||$l-y///c;$e=$_}{$\="$f$e"=~/\s/||$,
```
[Try it online!](https://tio.run/##LYoxCoAwEAR7XyGypXKVleQnQVFJRAgmGC3E06d7RrCagZlgVleLwDIrdA1c4kFEY4MyKbU6so4gZrjqDyad1wmtCliYQt2k4zeUIv0wZjb32eT3x4dt9kuUKrgX "Perl 5 – Try It Online")
Outputs `0` for truthy, any other number for falsey.
[Answer]
# [Red](http://www.red-lang.org), 216 191 bytes
```
func[s][d:(length?(first(s:(split(s)"^/"))))sp:
func[a][none = find a" "]b: on foreach c s[b: b
and(d = length? c )and(c/1 <>" ")and(" "<> last
c)]res:(sp(first(s)))and(sp(last(s)))and(b)res]
```
[Try it online!](https://tio.run/##bY7NTsMwEITv@xQrn5JTKbRArVLegatlJP82huAE2@FXffawiUrLAV/smfl2x8nZ8cFZIcHz0Q/RiCyF5VXr4r4095UPKZcq8yr3baBHzR4XrKaTew4zr6SIXXR4hz5Ei4ohk5pjF9F3ySnToMEsyNGgoq0sgcflFNSTZRZL3O5oblZ0b3fYqlzA1DK5ufv3H1Q8MWRMwEnrmjg59inEgh6@lTYWHPo9NOHp@QBwSl7fXSqfMGDAroevD/Om4998eXm1gjXiNdzcbi7OCTKFGg07GzMLqzWRuPmnAodwbIgvh/EH "Red – Try It Online")
I put a lot of otherwise not necessary parentheses in the first and last rows.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 17 bytes
```
Ỵµ.ịÐ€;ịɗẎ⁶e<L€E$
```
[Try it online!](https://tio.run/##y0rNyan8///h7i2Htuo93N19eMKjpjXWQMbJ6Q939T1q3JZq4wMUcVX5//9/YXlqUUklV6lCJldVRXJZUh4A "Jelly – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
Uses a method developed by Mnemonic in a (currently - due to an edge-case failure) deleted Pyth submission. (if it is now fixed up, [go give some credit](https://codegolf.stackexchange.com/a/163978/53748)!)
```
ỴµL€Eȧt€⁶ZUƊ4¡⁼
```
A monadic link accepting a list of characters which returns 1 or 0.
**[Try it online!](https://tio.run/##y0rNyan8///h7i2Htvo8alrjemJ5CZB61LgtKvRYl8mhhY8a9/z//z8xKTmFK1UhLZ0rIzMrGwA "Jelly – Try It Online")**
### How?
```
ỴµL€Eȧt€⁶ZUƊ4¡⁼ - Link: list of characters
Ỵ               - split at newlines (making a list of lists - the rows)
 µ              - start a new monadic chain, call that ROWS
  L€            - length of €ach row in ROWS
    E           - all equal? (an integer: 1 if so, otherwise 0)
            4¡  - repeat four times:
           Ɗ    -   last three links as a monad:
      t€⁶       -     trim spaces (⁶) from €ach row in current ROWS
         Z      -     transpose that result
          U     -     upend (reverse each new row)
     ȧ          - logical AND (0 if L€E was 0 else the result of the repeated transform)
              ⁼ - equal to X? (the integer 0 is not equal to any listy of characters)
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 22 bytes
Noncompeting answer: there's a [known bug in Japt](https://github.com/ETHproductions/japt/issues/38), where two-dimensional array rotations truncate the results. Due to that bug the code below only works on inputs that are square. If the bug wasn't present, though, the code below should work completely correctly.
```
e_Ê¶UÌÊÃ©Ueº4o)r_z)mx}U
e_                      // Check if every line in the input array
  Ê¶UÌÊ                 // has the same length as the last item.
       Ã©               // Also,
               r_z)mx}U // check if rotating and trimming the input array
           º4o)         // four times
         Ue             // is equal to the input array.
```
Takes input as an array of strings. Using parentheses instead of spaces makes the rectangular code requirement quite easy.  
[Try it here](https://ethproductions.github.io/japt/?v=1.4.5&code=ZV/KtlXMysOpVWW6NG8pcl96KW14fVU=&input=WyJhYmMiLAogImQgZSIsCiAiZmdoIl0=).
[Answer]
# [Ruby](https://www.ruby-lang.org/) 2.5+, 63 bytes
```
->a{!a.uniq(&:size)[1]&&a.none?(/^\s|\s$/)&&!(a[0]+a[-1])[?\s]}
```
Takes input as an array of strings. No test link, since the version on TIO (2.4) is too old for this one. Instead, here is a slightly longer (69 bytes) version for testing:
```
->a{!a.uniq(&:size)[1]&&a.none?{|l|l=~/^\s|\s$/}&&!(a[0]+a[-1])[?\s]}
```
[Try it online!](https://tio.run/##PY3tboJAFET/36dYE0MgrQsoaK2lPAjQ5AKLLB8LstBWgb66ro3tr8kkZ850Q3y@Zt519Y7jAukg@EnXXiW/MCOwI01DKhrB/HGqpsr7MT9COYVyac6attAxsKInDFZ2ZAR@KKP5unyjHcOUyrbivW6GYlzPpkEZJvk49Uz2E3r3eAB@KAxaY6sek7ypW@PQEnzOAlQqmR5zLEqZHQFQphkUZXUAOH2xrj/DQDhpWrh8J5@xALDXGwdcQrawe9lbahAnKTCitjkvStVJTJJfDBxXQWR/L7Bx3H8jGfhDKOo/4XYHSmfdAA "Ruby – Try It Online")
The difference is that since 2.5 Ruby supports directly passing a Regex pattern to `all?, any?, none?` methods, which saves us a few bytes. The method itself is quite self-explanatory - we test: 
1. If there is only 1 unique line size
2. If there are any spaces on line boundaries
3. If there are spaces on the first and last lines.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 119 bytes
Takes input as a list (s) of n strings.
```
f(s,n,m,r,p)char**s,*p;{for(r=m=n;m--;r*=strlen(*s)==strlen(s[m])&(!p||m&&m^n-1&&p!=s[m]&&p[1]))p=strchr(s[m],32);n=r;}
```
[Try it online!](https://tio.run/##xZLJboMwEIbP4SkmlooMMlLZ0gVx7Qu0tySViFmTYKgNbdM0z56aJURJuJcDzOBv5h/PDDUSSo/HGAvCSE44KTWaBlzXBdFLbx8XHHM/95mXG4bHdV9UfBsxrAvNP9lini81FU/L399cVfN3ZpiqWk795r805uZS08oGpilvYWJbmsd87h2On0UWQoIbSWg0IWMVME3ZK5OSSzvG6C5cMESgqVCeaJ5yUJSGyoOM4ZakBRMVdDkqXkfmfAk@7JEIkzRYb0ScoIN3i1k9FogwRgStN1tvlLN77uMr4tVOkjVkUJTS@Pmmnys2GuT0QaZlO5J0AWby8/D4dD@Ku6daVjSUXASyZoLSbL1p8cuAONiK4ZIBrIDe5GwR61yDTOa4bQXwNA7bAywp23HHKee6F1BnQytYPh7kXvVi9iDfshP3I3ejRRj1@D/tZF9UWVcCozdeV@nuecEM@SC5fJMEtytGwDx7FgHr7NkE7LPnXHhu753yL9hL06ErhW7Ag0Q3zCFPN65BspvL5emtzGu0jS9Fmk53EofjHw "C (gcc) – Try It Online\"nline")
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), ~~145~~ 167 bytes
```
S[0].Length>1&&S[0].IndexOf
(" ") + S[ S.Count() - 1 ].
IndexOf(" ")<-1&Array.Find(
S,x=>x[0]==' '| x [x.Length
-1]  ==  ' '  | S[0].Length
!=x.Length)==null?11>0:0>1;
```
[Try it online!](https://tio.run/##nVNdb9owFH1ufsVZHiDRRkRWaNdlYZqqMk3qtGmZtAfMQ0hMMJgbajtd6MdvZ4aWDSFtUnbfrn0@ro@uM93JSsU3lRZUIFlrw5eRc9gFl6WUPDOiJB185MSVyI4Q14Jujo6@89oE33hRyVRd1SvFtd4KRE4mU63xVZWFSpe4d2BLm9SIDLelyPE5FeRpo6zWaIxUFdrHDvQE3dalFSolD34oYbj15t7Qc3VezNL5Qk8L9@QkSFZSGK/NqO37fvRvZqrzKaP5QkZNmTc/uTJrRhUEyhWjuzq7nZDbTCR8fdpj1AfOGJ2/ueg2Hn@S5Yw4pgWjmZgvGvMxQWZJjadm1OtvZ8aF25jM6LTXb2y6zxuV2MdNy/@L@@yckQ37b2k//hY5XNBJWUoM/2xn4h9tpuKmUoRNMuqOg2tOhZkNwlZr136inNdfpo7nwvXxEskIif1bFRnPRwchxoHzjNlB3nXC1gel0nUwFJR7TvKqjge1VYrjNtoPqDGqnz2cTjgG4hiwN8ADDvydF/Ee5scxVVK@D8NB9213EEabp6c@bn4B "C# (.NET Core) – Try It Online")
```
S[0].Length>1&                                    // And if the lenght of the first argument is more than 1 char
Array.Find(                                       // Find a string in an array
    S,                                            // The array which will be searched in
    x=>                                           // For x as the current string from the array
    x.Length!=S[0].Length|                        // If the string lenght match not the first argument lenght
    x[0]==' '|                                    // Or if the string begins with a spacer
    x[x.Length-1]==' '                            // Or if the string ends with a spacer
)==null&                                          // And if there was no string found which matched the conditions
S[0].IndexOf(" ")+S[S.Count()-1].IndexOf(" ")<-1  // And if the first and last string doesn't have a spacer
?                                                 // If all above is true do
1>0                                               // Return True
:                                                 // Else
0>1                                               // Return False
```
]