Given that I have a function `sqrt[x]` that I must check the style and number of argument `x`.

I can do like this:

```
sqrt::badarg = "The argument `1` is not greater than or equal to zero.";
sqrt[x_] /;
 If[TrueQ[x >= 0], True, Message[sqrt::badarg, x]; False] := Sqrt[x]

```

**Test1**

```
sqrt[-1]

```

> 
> 
> ```
> sqrt::badarg: The argument -1 is not greater than or equal to zero.
> 
> ```
> 
> 

```
sqrt[1]

```

> 
> 
> ```
>  1
> 
> ```
> 
> 

```
sqrt[-1,2]

```

> 
> 
> ```
>  sqrt[-1,2]
> 
> ```
> 
> 

Now I have a function `func` which has three arguments `sample1,sample2 and c`.

The definition of `func` shown as belew:

In this case, I used the `If[]` to check the arguments step by step.

```
func::arrayerr = "`1` or `2` must be a valid 3D-array.";
func::badpara = "`1` must be a valid real number in the interval (0,1].";

func[sample1_, sample2_, c_] :=
 Module[{var1, var2},
  (*Check the argument that the user gives*)
  If[! (MatrixQ[sample1] && Length@First@sample1 == 3 &&
      MatrixQ[sample2] && Length@First@sample2 == 3),
    Message[func::arrayerr, sample1, sample2];
    Return[HoldForm@func[sample1, sample2, c]]
  ];
  If[! (0 < c <= 1),
    Message[func::badpara, c];
    Return[HoldForm@func[sample1, sample2, c]]
  ];
  (*main implementation*)
  c Join[sample1,sample2]
]

```

**Test2**

```
func[{{1, 2, 3}}, {{{1}, 2, 2, 3}}, 1]

```

> 
> 
> ```
> func::arrayerr: {{1,2,3}} or {{{1},2,2,3}} must be a valid 3D-array.
> 
> ```
> 
> 

```
func[{{1, 2, 3}}, {{4, 5, 6}, {7, 7, 2}}, 1]

```

> 
> 
> ```
> {{1, 2, 3}, {4, 5, 6}, {7, 7, 2}}
> 
> ```
> 
> 

```
func[{{1, 2}}, {{2, 2, 3, 4}}, 2]

```

> 
> 
> ```
> func::arrayerr: {{1,2}} or {{2,2,3,4}} must be a valid 3D-array.
> 
> ```
> 
> 

### Question

* Is it possible to know that how the *Mathematica* check the style and number of arguments for *built-in functions* ?
* When I input `func[{{1, 2}}, {{2, 2, 3, 4}}, 2, 4]`, how to give the warning information to user that the `func` only needs three arguments?
* Is it appropriate for my `If` solution?