Skip to main content

Fast Python JSON schema validation and normalization

Project description

Fast Python JSON schema validation and normalization

v = Validator({
  'User': {
    'items': {
      'name': {'coerce': 'str'},
      'gender': {
        'map': {
          'woman': 'female',
          'man': 'male',
          None: 'other'  # Map everything else
        'synonyms': ['sex']
      'country': {
        'default': '{GEOIP2_COUNTRY}'

args = {'GEOIP2_COUNTRY': 'UK'}

  'name': 123,
  'sex': 'woman'
}, args)

# Returns:
# ({
#    'name': '123',
#    'gender': 'female',
#    'country': 'UK'
#  },
#  None)  # Error description


Pycoercer was created to meet the actual production needs for web apps development - inspired by jsonschema and Cerberus, it also implements additional features: - Can validate, normalize (or coerce) dicts and lists - Fast - the schema is compiled into python code - Clean rules system with a predictable order of execution - Parametric default and if_null values - Keywords for data coercion: synonyms, map, and post_coerce - Check examples against the schema definition


$ pip install pycoercer


Complete documentation will be [sometime][docs]


$ pytest

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycoercer-0.1.2.tar.gz (7.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page