Uber warned earlier this year it would oppose any change of status for drivers, costing extra for company

Ride-hailing giant Uber and delivery company Postmates have filed a lawsuit against the state of California, claiming a new law that would treat gig-economy freelancers as employees is unconstitutional.

The legislation, due to go into effect on Wednesday, would mean that -- under certain conditions -- independent contractors are classified as employees and granted the minimum salary and health insurance benefits that entails.

This would include drivers for both Uber and Postmates.

"Plaintiffs bring this lawsuit to protect their constitutional rights and defend their fundamental liberty to pursue their chosen work as independent service providers and technology companies in the on-demand economy," said the lawsuit filed on Monday.

Uber warned earlier this year that it would oppose any change of status for its drivers, which will cost the company extra in social security costs.

In the suit, Uber and its co-plaintiffs argue the law targets independent service providers while exempting direct salespeople, travel agents, construction truck drivers and commercial fishermen.

"There is no rhyme or reason to these nonsensical exemptions," it said.

Uber and its American rival Lyft have each put aside 30 million dollars to organise a referendum, allowed under Californian law, to replace the legislation with a compromise on social rights that has been put before the state Governor.

Drivers are divided between those who want the same security as employees and those who want the flexibility of being able to choose the hours they work.

The gig economy has given drivers "opportunities to earn money when and where they want, with unprecedented independence and flexibility," the lawsuit said.