o
    Šåg§U  ã                   @   sv  d dl Z d dlZd dlZd dlZdZG dd„ deƒZG dd„ deƒZG dd„ dƒZ	G d	d
„ d
ƒZ
G dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ deƒZG dd„ deƒZG dd„ dƒZG dd „ d ƒZG d!d"„ d"ƒZG d#d$„ d$ƒZG d%d&„ d&ƒZG d'd(„ d(ƒZeZe	ZeZeZe
ZeZeZ eZ!eZ"eZ#eZ$eZ%eZ&eZ'eZ(dS ))é    N)!ÚDataRequiredÚdata_requiredÚEmailÚemailÚEqualToÚequal_toÚ	IPAddressÚ
ip_addressÚInputRequiredÚinput_requiredÚLengthÚlengthÚNumberRangeÚnumber_rangeÚOptionalÚoptionalÚRegexpÚregexpÚURLÚurlÚAnyOfÚany_ofÚNoneOfÚnone_ofÚ
MacAddressÚmac_addressÚUUIDÚValidationErrorÚStopValidationÚreadonlyÚReadOnlyÚdisabledÚDisabledc                   @   ó   e Zd ZdZddd„ZdS )r   z>
    Raised when a validator fails to validate its input.
    Ú c                 O   ó   t j| |g|¢R i |¤Ž d S ©N)Ú
ValueErrorÚ__init__©ÚselfÚmessageÚargsÚkwargs© r.   úN/var/www/html/flaskapp/venv/lib/python3.10/site-packages/wtforms/validators.pyr(   0   ó   zValidationError.__init__N©r$   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r(   r.   r.   r.   r/   r   +   s    r   c                   @   r#   )r   z×
    Causes the validation chain to stop.

    If StopValidation is raised, no more validators in the validation chain are
    called. If raised with a message, the message will be added to the errors
    list.
    r$   c                 O   r%   r&   )Ú	Exceptionr(   r)   r.   r.   r/   r(   =   r0   zStopValidation.__init__Nr1   r2   r.   r.   r.   r/   r   4   s    r   c                   @   ó"   e Zd ZdZddd„Zdd„ ZdS )r   a9  
    Compares the values of two fields.

    :param fieldname:
        The name of the other field to compare to.
    :param message:
        Error message to raise in case of a validation error. Can be
        interpolated with `%(other_label)s` and `%(other_name)s` to provide a
        more helpful error.
    Nc                 C   ó   || _ || _d S r&   )Ú	fieldnamer+   )r*   r:   r+   r.   r.   r/   r(   M   ó   
zEqualTo.__init__c              
   C   s’   z|| j  }W n ty } zt| d¡| j  ƒ|‚d }~ww |j|jkr'd S t|dƒr0|jjp2| j | j dœ}| j}|d u rC| d¡}t|| ƒ‚)NzInvalid field name '%s'.Úlabel)Úother_labelÚ
other_namez&Field must be equal to %(other_name)s.)	r:   ÚKeyErrorr   ÚgettextÚdataÚhasattrr<   Útextr+   )r*   ÚformÚfieldÚotherÚexcÚdr+   r.   r.   r/   Ú__call__Q   s,   ÿþ€ÿ
ÿü
zEqualTo.__call__r&   ©r3   r4   r5   r6   r(   rI   r.   r.   r.   r/   r   A   s    
r   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	r   a\  
    Validates the length of a string.

    :param min:
        The minimum required length of the string. If not provided, minimum
        length will not be checked.
    :param max:
        The maximum length of the string. If not provided, maximum length
        will not be checked.
    :param message:
        Error message to raise in case of a validation error. Can be
        interpolated using `%(min)d` and `%(max)d` if desired. Useful defaults
        are provided depending on the existence of min and max.

    When supported, sets the `minlength` and `maxlength` attributes on widgets.
    éÿÿÿÿNc                 C   s|   |dks|dksJ dƒ‚|dks||ksJ dƒ‚|| _ || _|| _i | _| j dkr/| j | jd< | jdkr<| j| jd< d S d S )NrK   z1At least one of `min` or `max` must be specified.z `min` cannot be more than `max`.Ú	minlengthÚ	maxlength©ÚminÚmaxr+   Úfield_flags©r*   rO   rP   r+   r.   r.   r/   r(   z   s   ÿ

ÿzLength.__init__c                 C   sÂ   |j rt|j ƒp	d}|| jkr| jdks|| jkrd S | jd ur$| j}n0| jdkr2| dd| j¡}n"| jdkr@| dd| j¡}n| j| jkrO| dd| j¡}n| d	¡}t|t| j| j|d
� ƒ‚)Nr   rK   z.Field must be at least %(min)d character long.z/Field must be at least %(min)d characters long.z.Field cannot be longer than %(max)d character.z/Field cannot be longer than %(max)d characters.z-Field must be exactly %(max)d character long.z.Field must be exactly %(max)d characters long.z:Field must be between %(min)d and %(max)d characters long.)rO   rP   r   )	rA   ÚlenrO   rP   r+   Úngettextr@   r   Údict)r*   rD   rE   r   r+   r.   r.   r/   rI   ˆ   s6   

ý
ýýÿzLength.__call__)rK   rK   NrJ   r.   r.   r.   r/   r   h   s    
r   c                   @   r8   )r   aÛ  
    Validates that a number is of a minimum and/or maximum value, inclusive.
    This will work with any comparable number type, such as floats and
    decimals, not just integers.

    :param min:
        The minimum required value of the number. If not provided, minimum
        value will not be checked.
    :param max:
        The maximum value of the number. If not provided, maximum value
        will not be checked.
    :param message:
        Error message to raise in case of a validation error. Can be
        interpolated using `%(min)s` and `%(max)s` if desired. Useful defaults
        are provided depending on the existence of min and max.

    When supported, sets the `min` and `max` attributes on widgets.
    Nc                 C   sL   || _ || _|| _i | _| j d ur| j | jd< | jd ur$| j| jd< d S d S )NrO   rP   rN   rR   r.   r.   r/   r(   ¾   s   

ÿzNumberRange.__init__c                 C   s¤   |j }|d ur"t |¡s"| jd u s|| jkr"| jd u s || jkr"d S | jd ur+| j}n| jd u r6| d¡}n| jd u rA| d¡}n| d¡}t|t| j| jd� ƒ‚)Nz Number must be at least %(min)s.zNumber must be at most %(max)s.z+Number must be between %(min)s and %(max)s.)rO   rP   )	rA   ÚmathÚisnanrO   rP   r+   r@   r   rU   ©r*   rD   rE   rA   r+   r.   r.   r/   rI   È   s   ÿ



zNumberRange.__call__)NNNrJ   r.   r.   r.   r/   r   ª   s    

r   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	r   al  
    Allows empty input and stops the validation chain from continuing.

    If input is empty, also removes prior errors (such as processing errors)
    from the field.

    :param strip_whitespace:
        If True (the default) also stop the validation chain on input which
        consists of only whitespace.

    Sets the `optional` attribute on widgets.
    Tc                 C   s(   |rdd„ | _ ndd„ | _ ddi| _d S )Nc                 S   s   |   ¡ S r&   )Ústrip©Úsr.   r.   r/   Ú<lambda>ó   s    z#Optional.__init__.<locals>.<lambda>c                 S   s   | S r&   r.   rZ   r.   r.   r/   r\   õ   s    r   T)Ústring_checkrQ   )r*   Ústrip_whitespacer.   r.   r/   r(   ñ   s   
zOptional.__init__c                 C   sB   |j rt|j d tƒr|  |j d ¡sg |jd d …< tƒ ‚d S d S )Nr   )Úraw_dataÚ
isinstanceÚstrr]   Úerrorsr   ©r*   rD   rE   r.   r.   r/   rI   ù   s   ÿþýúzOptional.__call__N)TrJ   r.   r.   r.   r/   r   ã   s    
r   c                   @   r8   )r   aù  
    Checks the field's data is 'truthy' otherwise stops the validation chain.

    This validator checks that the ``data`` attribute on the field is a 'true'
    value (effectively, it does ``if field.data``.) Furthermore, if the data
    is a string type, a string containing only whitespace characters is
    considered false.

    If the data is empty, also removes prior errors (such as processing errors)
    from the field.

    **NOTE** this validator used to be called `Required` but the way it behaved
    (requiring coerced data, not input data) meant it functioned in a way
    which was not symmetric to the `Optional` validator and furthermore caused
    confusion with certain fields which coerced data to 'falsey' values like
    ``0``, ``Decimal(0)``, ``time(0)`` etc. Unless a very specific reason
    exists, we recommend using the :class:`InputRequired` instead.

    :param message:
        Error message to raise in case of a validation error.

    Sets the `required` attribute on widgets.
    Nc                 C   ó   || _ ddi| _d S ©NÚrequiredT©r+   rQ   ©r*   r+   r.   r.   r/   r(     ó   zDataRequired.__init__c                 C   sR   |j rt|j tƒr|j  ¡ rd S | jd u r| d¡}n| j}g |jd d …< t|ƒ‚)NúThis field is required.)rA   r`   ra   rY   r+   r@   rb   r   ©r*   rD   rE   r+   r.   r.   r/   rI      s   
zDataRequired.__call__r&   rJ   r.   r.   r.   r/   r     s    
r   c                   @   r8   )r
   aÞ  
    Validates that input was provided for this field.

    Note there is a distinction between this and DataRequired in that
    InputRequired looks that form-input data was provided, and DataRequired
    looks at the post-coercion data. This means that this validator only checks
    whether non-empty data was sent, not whether non-empty data was coerced
    from that data. Initially populated data is not considered sent.

    Sets the `required` attribute on widgets.
    Nc                 C   rd   re   rg   rh   r.   r.   r/   r(   :  ri   zInputRequired.__init__c                 C   sF   |j r
|j d r
d S | jd u r| d¡}n| j}g |jd d …< t|ƒ‚)Nr   rj   )r_   r+   r@   rb   r   rk   r.   r.   r/   rI   >  s   
zInputRequired.__call__r&   rJ   r.   r.   r.   r/   r
   -  s    
r
   c                   @   s$   e Zd ZdZddd„Zd	dd„ZdS )
r   a…  
    Validates the field against a user provided regexp.

    :param regex:
        The regular expression string to use. Can also be a compiled regular
        expression pattern.
    :param flags:
        The regexp flags to use, for example re.IGNORECASE. Ignored if
        `regex` is not a string.
    :param message:
        Error message to raise in case of a validation error.
    r   Nc                 C   s&   t |tƒrt ||¡}|| _|| _d S r&   )r`   ra   ÚreÚcompileÚregexr+   )r*   rn   Úflagsr+   r.   r.   r/   r(   Y  s   

zRegexp.__init__c                 C   sL   | j  |jpd¡}|r|S |d u r"| jd u r| d¡}t|ƒ‚| j}t|ƒ‚)Nr$   zInvalid input.)rn   ÚmatchrA   r+   r@   r   ©r*   rD   rE   r+   rp   r.   r.   r/   rI   _  s   

þzRegexp.__call__)r   Nr&   rJ   r.   r.   r.   r/   r   K  s    
r   c                   @   s,   e Zd ZdZ					d	dd„Zdd„ ZdS )
r   a±  
    Validates an email address. Requires email_validator package to be
    installed. For ex: pip install wtforms[email].

    :param message:
        Error message to raise in case of a validation error.
    :param granular_message:
        Use validation failed message from email_validator library
        (Default False).
    :param check_deliverability:
        Perform domain name resolution check (Default False).
    :param allow_smtputf8:
        Fail validation for addresses that would require SMTPUTF8
        (Default True).
    :param allow_empty_local:
        Allow an empty local part (i.e. @example.com), e.g. for validating
        Postfix aliases (Default False).
    NFTc                 C   s"   || _ || _|| _|| _|| _d S r&   )r+   Úgranular_messageÚcheck_deliverabilityÚallow_smtputf8Úallow_empty_local)r*   r+   rr   rs   rt   ru   r.   r.   r/   r(   �  s
   
zEmail.__init__c              
   C   s²   zdd l }W n ty } ztdƒ|‚d }~ww z|jd u r"| ¡ ‚|j|j| j| j| jd� W d S  |jyX } z| j	}|d u rO| j
rJ| |¡}n| d¡}t|ƒ|‚d }~ww )Nr   z7Install 'email_validator' for email validation support.)rs   rt   ru   zInvalid email address.)Úemail_validatorÚImportErrorr7   rA   ÚEmailNotValidErrorÚvalidate_emailrs   rt   ru   r+   rr   r@   r   )r*   rD   rE   rv   rG   Úer+   r.   r.   r/   rI   �  s8   ÿþ€ÿ
ü

€ùzEmail.__call__)NFFTFrJ   r.   r.   r.   r/   r   m  s    
úr   c                   @   s:   e Zd ZdZddd„Zdd„ Zed	d
„ ƒZedd„ ƒZdS )r   a  
    Validates an IP address.

    :param ipv4:
        If True, accept IPv4 addresses as valid (default True)
    :param ipv6:
        If True, accept IPv6 addresses as valid (default False)
    :param message:
        Error message to raise in case of a validation error.
    TFNc                 C   s&   |s|st dƒ‚|| _|| _|| _d S )NzDIP Address Validator must have at least one of ipv4 or ipv6 enabled.)r'   Úipv4Úipv6r+   )r*   r{   r|   r+   r.   r.   r/   r(   ¶  s   ÿ
zIPAddress.__init__c                 C   sV   |j }d}|r| jr|  |¡p| jo|  |¡}|rd S | j}|d u r'| d¡}t|ƒ‚)NFzInvalid IP address.)rA   r{   Ú
check_ipv4r|   Ú
check_ipv6r+   r@   r   )r*   rD   rE   ÚvalueÚvalidr+   r.   r.   r/   rI   ¿  s   ÿ
zIPAddress.__call__c                 C   ó8   zt  |¡}W n
 ty   Y dS w t|t jƒsdS dS ©NFT)Ú	ipaddressr	   r'   r`   ÚIPv4Address©Úclsr   Úaddressr.   r.   r/   r}   Ï  ó   ÿzIPAddress.check_ipv4c                 C   r�   r‚   )rƒ   r	   r'   r`   ÚIPv6Addressr…   r.   r.   r/   r~   Û  rˆ   zIPAddress.check_ipv6)TFN)	r3   r4   r5   r6   r(   rI   Úclassmethodr}   r~   r.   r.   r.   r/   r   ª  s    
	
r   c                       s.   e Zd ZdZd‡ fdd„	Z‡ fdd„Z‡  ZS )r   zu
    Validates a MAC address.

    :param message:
        Error message to raise in case of a validation error.
    Nc                    s   d}t ƒ j||d� d S )Nz&^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$©r+   )Úsuperr(   )r*   r+   Úpattern©Ú	__class__r.   r/   r(   ð  s   zMacAddress.__init__c                    s,   | j }|d u r| d¡}tƒ  |||¡ d S )NzInvalid Mac address.)r+   r@   rŒ   rI   rk   rŽ   r.   r/   rI   ô  s   
zMacAddress.__call__r&   ©r3   r4   r5   r6   r(   rI   Ú__classcell__r.   r.   rŽ   r/   r   è  s    r   c                       s.   e Zd ZdZd‡ fdd„	Z‡ fdd„Z‡  ZS )	r   a  
    Simple regexp based url validation. Much like the email validator, you
    probably want to validate the url later by other means if the url must
    resolve.

    :param require_tld:
        If true, then the domain-name portion of the URL must contain a .tld
        suffix.  Set this to false if you want to allow domains like
        `localhost`.
    :param allow_ip:
        If false, then give ip as host will fail validation
    :param message:
        Error message to raise in case of a validation error.
    TNc                    s(   d}t ƒ  |tj|¡ t||d�| _d S )NzP^[a-z]+://(?P<host>[^\/\?:]+)(?P<port>:[0-9]+)?(?P<path>\/.*?)?(?P<query>\?.*)?$©Úrequire_tldÚallow_ip)rŒ   r(   rl   Ú
IGNORECASEÚHostnameValidationÚvalidate_hostname)r*   r“   r”   r+   rn   rŽ   r.   r/   r(     s   ÿÿzURL.__init__c                    sD   | j }|d u r| d¡}tƒ  |||¡}|  | d¡¡s t|ƒ‚d S )NzInvalid URL.Úhost)r+   r@   rŒ   rI   r—   Úgroupr   rq   rŽ   r.   r/   rI     s   
ÿzURL.__call__)TTNr�   r.   r.   rŽ   r/   r   ü  s    r   c                   @   r8   )r   zn
    Validates a UUID.

    :param message:
        Error message to raise in case of a validation error.
    Nc                 C   s
   || _ d S r&   r‹   rh   r.   r.   r/   r(   +  s   
zUUID.__init__c              
   C   sN   | j }|d u r| d¡}z	t |j¡ W d S  ty& } zt|ƒ|‚d }~ww )NzInvalid UUID.)r+   r@   Úuuidr   rA   r'   r   )r*   rD   rE   r+   rG   r.   r.   r/   rI   .  s   

€ÿzUUID.__call__r&   rJ   r.   r.   r.   r/   r   #  s    
r   c                   @   ó.   e Zd ZdZd	dd„Zdd„ Zedd„ ƒZdS )
r   ae  
    Compares the incoming data to a sequence of valid inputs.

    :param values:
        A sequence of valid inputs.
    :param message:
        Error message to raise in case of a validation error. `%(values)s`
        contains the list of values.
    :param values_formatter:
        Function used to format the list of values in the error message.
    Nc                 C   ó$   || _ || _|d u r| j}|| _d S r&   ©Úvaluesr+   Údefault_values_formatterÚvalues_formatter©r*   rž   r+   r    r.   r.   r/   r(   E  ó
   
zAnyOf.__init__c                    sf   t |jtƒr	|jn|jg}t‡ fdd„|D ƒƒrd S ˆ j}|d u r&| d¡}t|tˆ  ˆ j	¡d� ƒ‚)Nc                 3   ó   � | ]}|ˆ j v V  qd S r&   ©rž   ©Ú.0rH   ©r*   r.   r/   Ú	<genexpr>N  ó   € z!AnyOf.__call__.<locals>.<genexpr>z*Invalid value, must be one of: %(values)s.r¤   ©
r`   rA   ÚlistÚanyr+   r@   r   rU   r    rž   rX   r.   r§   r/   rI   L  ó   
zAnyOf.__call__c                 C   ó   d  dd„ | D ƒ¡S )Nú, c                 s   ó   � | ]}t |ƒV  qd S r&   ©ra   ©r¦   Úxr.   r.   r/   r¨   Y  ó   € z1AnyOf.default_values_formatter.<locals>.<genexpr>©Újoinr¤   r.   r.   r/   rŸ   W  ó   zAnyOf.default_values_formatter©NN©r3   r4   r5   r6   r(   rI   ÚstaticmethodrŸ   r.   r.   r.   r/   r   8  ó    
r   c                   @   r›   )
r   ai  
    Compares the incoming data to a sequence of invalid inputs.

    :param values:
        A sequence of invalid inputs.
    :param message:
        Error message to raise in case of a validation error. `%(values)s`
        contains the list of values.
    :param values_formatter:
        Function used to format the list of values in the error message.
    Nc                 C   rœ   r&   r�   r¡   r.   r.   r/   r(   i  r¢   zNoneOf.__init__c                    sf   t |jtƒr	|jn|jg}t‡ fdd„|D ƒƒsd S ˆ j}|d u r&| d¡}t|tˆ  ˆ j	¡d� ƒ‚)Nc                 3   r£   r&   r¤   r¥   r§   r.   r/   r¨   r  r©   z"NoneOf.__call__.<locals>.<genexpr>z+Invalid value, can't be any of: %(values)s.r¤   rª   rX   r.   r§   r/   rI   p  r­   zNoneOf.__call__c                 C   r®   )Nr¯   c                 s   r°   r&   r±   r²   r.   r.   r/   r¨   }  r´   z2NoneOf.default_values_formatter.<locals>.<genexpr>rµ   )Úvr.   r.   r/   rŸ   {  r·   zNoneOf.default_values_formatterr¸   r¹   r.   r.   r.   r/   r   \  r»   r   c                   @   s>   e Zd ZdZe dej¡Ze dej¡Zddd„Z	dd	„ Z
d
S )r–   z‰
    Helper class for checking hostnames for validation.

    This is not a validator in and of itself, and as such is not exported.
    z!^(xn-|[a-z0-9_]+)(-[a-z0-9_-]+)*$z*^([a-z]{2,20}|xn--([a-z0-9]+-)*[a-z0-9]+)$TFc                 C   r9   r&   r’   )r*   r“   r”   r.   r.   r/   r(   Š  r;   zHostnameValidation.__init__c                 C   sÊ   | j rt |¡st |¡rdS z| d¡}W n	 ty   Y nw t|tƒs*| d¡}t	|ƒdkr2dS | 
d¡}|D ]}|rCt	|ƒdkrF dS | j |¡sO dS q9| jrct	|ƒdk sa| j |d	 ¡scdS dS )
NTÚidnaÚasciiéý   FÚ.é?   é   rK   )r”   r   r}   r~   ÚencodeÚUnicodeErrorr`   ra   ÚdecoderS   ÚsplitÚhostname_partrp   r“   Útld_part)r*   ÚhostnameÚpartsÚpartr.   r.   r/   rI   Ž  s2   ÿÿÿ


ÿ"zHostnameValidation.__call__N)TF)r3   r4   r5   r6   rl   rm   r•   rÇ   rÈ   r(   rI   r.   r.   r.   r/   r–   €  s    
r–   c                   @   ó    e Zd ZdZdd„ Zdd„ ZdS )r    z�
    Set a field readonly.

    Validation fails if the form data is different than the
    field object data, or if unset, from the field default data.
    c                 C   ó   ddi| _ d S )Nr   T©rQ   r§   r.   r.   r/   r(   ·  ó   zReadOnly.__init__c                 C   s   |j |jkrt| d¡ƒ‚d S )NzThis field cannot be edited.)rA   Úobject_datar   r@   rc   r.   r.   r/   rI   º  s   ÿzReadOnly.__call__NrJ   r.   r.   r.   r/   r    ¯  s    r    c                   @   rÌ   )r"   zU
    Set a field disabled.

    Validation fails if the form data has any value.
    c                 C   rÍ   )Nr!   TrÎ   r§   r.   r.   r/   r(   Æ  rÏ   zDisabled.__init__c                 C   s   |j d urt| d¡ƒ‚d S )Nz/This field is disabled and cannot have a value.)r_   r   r@   rc   r.   r.   r/   rI   É  s
   
ÿÿzDisabled.__call__NrJ   r.   r.   r.   r/   r"   ¿  s    r"   ))rƒ   rV   rl   rš   Ú__all__r'   r   r7   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r–   r    r"   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r!   r.   r.   r.   r/   Ú<module>   sN    %	'B9 *"=>'$$/