For degrees of freedom of a planar mechanism (flat) the Grübler formula:

DOF = 3(n - 1) - 2l1 -l2

Where n = number of bodies (number of links including sliders)
l1 = number of joints with 1 dof (pivot on its own and slider on its own count as one dof)
l2 = number of joints with 2 dof (pivot on a slider)


Should be easy enough to check if a 2d mechanism adheres to the rules.