Skip to main content

Layrz forms and tools for Python

Project description

Form tools - Layrz

Managed by Golden M, Inc.

Motivation

This project is a collection of tools that we use to make django developers life easier. I hope you find them useful too.

Usage

The idea is simple, replace the django forms to a more easier way to use them. Also provide the ability to return the errors key to support i18n.

import layrz.forms as forms


class ExampleForm(forms.Form):
  """ Example form """
  id_test = forms.IdField(required=True)
  email_text = forms.EmailField(required=True)
  json_list_test = forms.JsonField(required=True, datatype=list)
  json_dict_test = forms.JsonField(required=True, datatype=dict)
  int_test = forms.NumberField(required=True, datatype=int, min_value=0, max_value=5)
  float_test = forms.NumberField(required=True, datatype=float, min_value=0, max_value=5)
  bool_test = forms.BooleanField(required=True)
  plain_text_test = forms.CharField(required=True, empty=False)
  empty_text_test = forms.CharField(required=True, empty=True)
  range_text_test = forms.CharField(required=True, empty=False, min_length=5, max_length=10)

  def clean_func1(self):
    """ Print clean """
    self.add_errors(key='clean1', code='error1')
    self.add_errors(key='clean1', code='error2')

  def clean_func2(self):
    self.add_errors(key='clean2', code='error1')


if __name__ == '__main__':
  obj = {
    'id_test': 1,
    'email_text': 'example@goldenmcorp.com',
    'json_dict_test': {
      'hola': 'mundo'
    },
    'json_list_test': ['hola mundo'],
    'int_test': 5,
    'float_test': 4.5,
    'bool_test': True,
    'plain_text_test': 'hola mundo',
    'empty_text_test': 'hola',
    'range_text_test': 'hola'
  }

  form = ExampleForm(obj)

  print('form.is_valid():', form.is_valid())
  #> form.is_valid(): None
  print('form.errors():', form.errors())
  #> form.errors(): {'rangeTextTest': [{'code': 'minLength', 'expected': 5, 'received': 4}], 'clean1': [{'code': 'error1'}, {'code': 'error2'}], 'clean2': [{'code': 'error1'}]}

Work with us

Golden M is a software/hardware development company what is working on a new, innovative and disruptive technologies.

For more information, contact us at sales@goldenmcorp.com

License

This project is under MIT License, for more information, check out the LICENCE

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

layrz-forms-1.0.11.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

layrz_forms-1.0.11-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file layrz-forms-1.0.11.tar.gz.

File metadata

  • Download URL: layrz-forms-1.0.11.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for layrz-forms-1.0.11.tar.gz
Algorithm Hash digest
SHA256 2615fbca2420c6f192644ccc77c55bfeff30323b6880c19268fd732daea6916c
MD5 cc29489de6c3963eb9f43ca07097a0fc
BLAKE2b-256 66d70596d5f64d21283d2999715a155c4d3988aeea78bf60fb7327ab6d923cbb

See more details on using hashes here.

File details

Details for the file layrz_forms-1.0.11-py3-none-any.whl.

File metadata

  • Download URL: layrz_forms-1.0.11-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for layrz_forms-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 d74d3f750acf37d7b7067e69ca1885c9cafa8b85b0b7d4f857260add9aa20b57
MD5 6732422ea779b92837c4bb57836143f1
BLAKE2b-256 3067a8c55b570ec104389b07335c79088da7aa76fe3c33cecd2c5f1f951d3992

See more details on using hashes here.

Supported by

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