AndreaCensi / contracts

PyContracts is a Python package that allows to declare constraints on function parameters and return values. Contracts can be specified using Python3 annotations, or inside a docstring. PyContracts supports a basic type system, variables binding, arithmetic constraints, and has several specialized contracts and an extension API.
http://andreacensi.github.io/contracts/
Other
399 stars 61 forks source link

Improve string support #11

Open dalbani opened 11 years ago

dalbani commented 11 years ago

Hello,

Starting from a very simple integer-related contract: int,(-1 | 1)

I've tried to write the same kind of contract, but for string values, e.g.: string,(a | b)

Unfortunately, that syntax is not accepted by PyContracts.

It would also be nice to introduce regexp in contracts, to be matched against string values.

Thanks.