Skip to main content

Forms for aiogram

Project description

aiogram-forms

PyPI - Python Version PyPI GitHub PyPI - Downloads

Introduction

aiogram-forms is an addition for aiogram which allows you to create different forms and process user input step by step easily.

Installation

pip install aiogram-forms

Usage

Create form you need by subclassing aiogram_forms.forms.Form. Fields can be added with aiogram_forms.fields.Field. For more examples refer to examples folder.

class UserProfileForm(forms.Form):
    """Example of user details form."""

    # Simple field usage
    name = fields.StringField('Name')
    # Using custom validators
    username = fields.StringField(
        'Username', validators=[validators.RegexValidator(r'^[a-z0-9_-]{3,15}$')]
    )
    # Custom reply keyboard with validation
    language = fields.ChoicesField(
        'Language', LANGUAGE_CHOICES, reply_keyboard=LANGUAGE_KEYBOARD
    )
    # Custom validation message
    email = fields.EmailField(
        'Email', validation_error_message='Wrong email format!'
    )
    # Allow user to share contact as reply
    phone = fields.PhoneNumberField(
        'Phone', share_contact=True, share_contact_label='Share your contact'
    )

History

All notable changes to this project will be documented in CHANGELOG file.

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

aiogram_forms-0.3.0.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

aiogram_forms-0.3.0-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

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