see tutorial/PatternsOverview this below from tutorial/PuttingConstraintsOnPatterns
See also what-is-the-recommended-way-to-check-that-a-list-is-a-list-of-numbers-in-argumen
foo[(x_)?(Element[#1, Integers] & )] := x foo[x_Integer] := x foo[x_Integer] := x
foo[(x_)?(IntegerQ[#1] && #1 > 0 & )] := x foo[x_Integer /; x > 0] := x foo[(x_Integer)?Positive] := x foo[x_Integer /; x > 0] := x
foo[(x_)?(IntegerQ[#1] && #1 < 0 & )] := x foo[x_Integer /; x < 0] := x foo[(x_Integer)?Negative] := x foo[x_Integer /; x < 0] := x
foo[(x_)?(IntegerQ[#1] && #1 >= 0 & )] := x foo[x_Integer /; x >= 0] := x foo[(x_Integer)?NonNegative] := x foo[x_Integer /; x >= 0] := x
foo[(x_)?(IntegerQ[#1] && #1 <= 0 & )] := x foo[x_Integer /; x <= 0] := x foo[(x_Integer)?NonPositive] := x foo[x_Integer /; x <= 0] := x
foo[x_Integer /; x > 3 && x < 7] := x
foo[x_?(Element[#, Reals] &)] := x foo[x_Real] := x
foo[x_Real /; x > $MachineEpsilon] := x foo[x_Real /; x > $MachineEpsilon] := x foo[x_Real /; Positive[x]] := x foo[x_ (Element[#, Reals] && Positive[#] &)] := x
foo[x_Real /; x < $MachineEpsilon] := x foo[x_Real /; x < $MachineEpsilon] := x foo[x_Real /; Negative[x]] := x foo[x_?(Element[#, Reals] && Negative[#] &)] := x
foo[x_Real /; x >= $MachineEpsilon] := x foo[x_Real /; x >= $MachineEpsilon] := x foo[x_Real /; Positive[x] || x == 0] := x foo[x_ (Element[#, Reals] && (Positive[#] || # == 0) &)] := x
foo[x_Real /; x <= $MachineEpsilon] := x foo[x_Real /; x <= $MachineEpsilon] := x foo[x_Real /; Negative[x] || x == 0] := x foo[x_ (Element[#, Reals] && (Negative[#] || # == 0) &)] := x
foo[x_ (Element[#, Reals] && ((# - 3) > $MachineEpsilon && (7 - #) > $MachineEpsilon) &)] := x foo[x : _Real /; (x - 3) > $MachineEpsilon && (7 - x) > $MachineEpsilon] := x
foo[x_?(Element[#, Booleans] &)] := x
foo[x_?(Element[#, Reals] &)] := x foo[x_?(NumericQ[#] &)] := x foo[x : _?NumericQ] := x
foo[x_?(NumberQ[#] &)] := x
foo[x_Complex] := x foo[x_?(Not@FreeQ[#, _Complex] &)] := x
foo[x_List] := x
foo[x_?(VectorQ[#] &)] := x
foo[x_?(VectorQ[#, NumericQ] &)] := x
foo[x_?(VectorQ[#, NumericQ] &)] := x foo[x : {_?NumericQ ..}] := x foo[x : {__?NumericQ }] := x foo[x_?(VectorQ[#, IntegerQ] &)] := x
foo[x_?(MatrixQ[#, NumericQ] &)] := x foo[x : {{_?NumericQ ..}}] := x foo[x : {{__?NumericQ }}] := x
foo[x_?(MatrixQ[#, NumericQ] && FreeQ[#, _Complex] &)] := x
foo[x_?(MatrixQ[#, StringQ] &)] := x