# 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.
```python
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@goldenm.com](mailto:sales@goldenm.com)
## License
This project is under MIT License, for more information, check out the `LICENCE`
Raw data
{
"_id": null,
"home_page": null,
"name": "layrz-forms",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Kenny Mochizuki <kenny@goldenm.com>, Miguel Zauzich <miguel@goldenm.com>",
"keywords": "sdk, goldenm, layrz, django forms, django, forms",
"author": null,
"author_email": "\"Golden M, Inc.\" <software@goldenm.com>",
"download_url": "https://files.pythonhosted.org/packages/91/fe/23587c5b17055a9a9391f86c027d7aacd641cdb7763d3140c43b6f473278/layrz-forms-2.0.1.tar.gz",
"platform": null,
"description": "# Form tools - Layrz\nManaged by Golden M, Inc.\n\n## Motivation\nThis project is a collection of tools that we use to make django developers life easier. I hope you find them useful too.\n\n## Usage\nThe 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.\n\n```python\nimport layrz_forms as forms\n\n\nclass ExampleForm(forms.Form):\n \"\"\" Example form \"\"\"\n id_test = forms.IdField(required=True)\n email_text = forms.EmailField(required=True)\n json_list_test = forms.JsonField(required=True, datatype=list)\n json_dict_test = forms.JsonField(required=True, datatype=dict)\n int_test = forms.NumberField(required=True, datatype=int, min_value=0, max_value=5)\n float_test = forms.NumberField(required=True, datatype=float, min_value=0, max_value=5)\n bool_test = forms.BooleanField(required=True)\n plain_text_test = forms.CharField(required=True, empty=False)\n empty_text_test = forms.CharField(required=True, empty=True)\n range_text_test = forms.CharField(required=True, empty=False, min_length=5, max_length=10)\n\n def clean_func1(self):\n \"\"\" Print clean \"\"\"\n self.add_errors(key='clean1', code='error1')\n self.add_errors(key='clean1', code='error2')\n\n def clean_func2(self):\n self.add_errors(key='clean2', code='error1')\n\n\nif __name__ == '__main__':\n obj = {\n 'id_test': 1,\n 'email_text': 'example@goldenmcorp.com',\n 'json_dict_test': {\n 'hola': 'mundo'\n },\n 'json_list_test': ['hola mundo'],\n 'int_test': 5,\n 'float_test': 4.5,\n 'bool_test': True,\n 'plain_text_test': 'hola mundo',\n 'empty_text_test': 'hola',\n 'range_text_test': 'hola'\n }\n\n form = ExampleForm(obj)\n\n print('form.is_valid():', form.is_valid())\n #> form.is_valid(): None\n print('form.errors():', form.errors())\n #> form.errors(): {'rangeTextTest': [{'code': 'minLength', 'expected': 5, 'received': 4}], 'clean1': [{'code': 'error1'}, {'code': 'error2'}], 'clean2': [{'code': 'error1'}]}\n```\n\n## Work with us\nGolden M is a software/hardware development company what is working on\na new, innovative and disruptive technologies.\n\nFor more information, contact us at [sales@goldenm.com](mailto:sales@goldenm.com)\n\n## License\nThis project is under MIT License, for more information, check out the `LICENCE`\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Layrz forms and tools for Python",
"version": "2.0.1",
"project_urls": {
"Changelog": "https://github.com/goldenm-software/layrz-forms/blob/main/CHANGELOG.md",
"Repository": "https://github.com/goldenm-software/layrz-forms"
},
"split_keywords": [
"sdk",
" goldenm",
" layrz",
" django forms",
" django",
" forms"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "82a92939b983d7efcec89e73a5c15a610e53500c79517ed4bc7086ba690bbdee",
"md5": "2ebb546d05a40f4c10e84fde1dc892e2",
"sha256": "8a79264e57166c0d5b3e95e68e0f77656e8c7f41d82aa3bb55ccd011b9a855e5"
},
"downloads": -1,
"filename": "layrz_forms-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2ebb546d05a40f4c10e84fde1dc892e2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 10712,
"upload_time": "2024-04-13T00:15:54",
"upload_time_iso_8601": "2024-04-13T00:15:54.556077Z",
"url": "https://files.pythonhosted.org/packages/82/a9/2939b983d7efcec89e73a5c15a610e53500c79517ed4bc7086ba690bbdee/layrz_forms-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "91fe23587c5b17055a9a9391f86c027d7aacd641cdb7763d3140c43b6f473278",
"md5": "4f37778747a54fdfffcba08b9593a393",
"sha256": "7ecc260e7aa1c30378cbf3c72cd850533b68b45bfbd2ead4b8264995c99b4c0a"
},
"downloads": -1,
"filename": "layrz-forms-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "4f37778747a54fdfffcba08b9593a393",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 10277,
"upload_time": "2024-04-13T00:15:56",
"upload_time_iso_8601": "2024-04-13T00:15:56.667461Z",
"url": "https://files.pythonhosted.org/packages/91/fe/23587c5b17055a9a9391f86c027d7aacd641cdb7763d3140c43b6f473278/layrz-forms-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-13 00:15:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "goldenm-software",
"github_project": "layrz-forms",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "layrz-forms"
}