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.5.tar.gz (7.6 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.5-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for layrz-forms-1.0.5.tar.gz
Algorithm Hash digest
SHA256 c6a99e4fa1e05c154f2f8b9b49e1a8233f2835bf0fa2a1dd32e1cfc2fc413365
MD5 e2d5f2bb01627b9427484bf291143d83
BLAKE2b-256 b26961de9d4aa707b75dd23fce74fff1d140ca9c9ab8b699ebc772b327108ffa

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for layrz_forms-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1751ed9ab65f536f129df988a59401cb5de2e5adfc46b5bcffa4a77b7a2f3d28
MD5 0fcc5a24709f5a4d712f75785bad9190
BLAKE2b-256 a63c6c97aafcf906c262ebe46cafb7433523ad37ba9f35b7ee13a0de8a3f0a36

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