Hello community, here is the log from the commit of package python-validators for openSUSE:Leap:15.2 checked in at 2020-03-02 13:24:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-validators (Old) and /work/SRC/openSUSE:Leap:15.2/.python-validators.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-validators" Mon Mar 2 13:24:35 2020 rev:5 rq:777257 version:0.14.2 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-validators/python-validators.changes 2020-01-15 15:54:02.859618686 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-validators.new.26092/python-validators.changes 2020-03-02 13:24:36.210547023 +0100 @@ -1,0 +2,37 @@ +Fri Jan 24 21:49:23 UTC 2020 - Martin Herkt <[email protected]> + +- Update to 0.14.2: + * Made domain validation case-insensitive + +------------------------------------------------------------------- +Thu Dec 5 23:15:30 UTC 2019 - Martin Herkt <[email protected]> + +- Update to 0.14.1: + * Updated domain validator regex to not allow numeric only TLDs + * Allow for idna encoded domains + +------------------------------------------------------------------- +Tue Sep 10 09:25:32 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 0.14.0: + * Added new validators ipv4_cidr, ipv6_cidr + +------------------------------------------------------------------- +Fri May 24 19:11:44 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 0.13.0: + * Added new validator: es_doi, es_nif, es_cif, es_nie (#121, pull request courtesy kingbuzzman) + +------------------------------------------------------------------- +Wed May 22 15:16:16 UTC 2019 - [email protected] + +- version update to 0.12.6 + * Fixed domain validator for single character domains + +------------------------------------------------------------------- +Tue Apr 16 16:01:41 UTC 2019 - Martin Herkt <[email protected]> + +- Update to 0.12.5 + * Fixed py37 support + +------------------------------------------------------------------- Old: ---- validators-0.12.4.tar.gz New: ---- validators-0.14.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-validators.spec ++++++ --- /var/tmp/diff_new_pack.G0yW1p/_old 2020-03-02 13:24:36.742548081 +0100 +++ /var/tmp/diff_new_pack.G0yW1p/_new 2020-03-02 13:24:36.746548089 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-validators # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,26 +18,25 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-validators -Version: 0.12.4 +Version: 0.14.2 Release: 0 Summary: Python Data Validation License: MIT Group: Development/Languages/Python -Url: https://github.com/kvesteri/validators +URL: https://github.com/kvesteri/validators Source: https://files.pythonhosted.org/packages/source/v/validators/validators-%{version}.tar.gz BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros +Requires: python-decorator >= 3.4.0 +Requires: python-six >= 1.4.0 +BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module decorator >= 3.4.0} -BuildRequires: %{python_module nose} +BuildRequires: %{python_module isort >= 4.2.2} BuildRequires: %{python_module pytest} BuildRequires: %{python_module six >= 1.4.0} # /SECTION -Requires: python-decorator >= 3.4.0 -Requires: python-six >= 1.4.0 -BuildArch: noarch - %python_subpackages %description @@ -54,7 +53,7 @@ %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_expand py.test-%{$python_bin_suffix} +%pytest %files %{python_files} %doc CHANGES.rst README.rst ++++++ validators-0.12.4.tar.gz -> validators-0.14.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/CHANGES.rst new/validators-0.14.2/CHANGES.rst --- old/validators-0.12.4/CHANGES.rst 2019-01-02 16:38:52.000000000 +0100 +++ new/validators-0.14.2/CHANGES.rst 2020-01-24 10:58:05.000000000 +0100 @@ -2,6 +2,43 @@ --------- +0.14.2 (2020-01-24) +^^^^^^^^^^^^^^^^^^^ + +- Made domain validation case-insensitive (#136, pull request courtesy ehmkah) + + +0.14.1 (2019-12-04) +^^^^^^^^^^^^^^^^^^^ + +- Updated domain validator regex to not allow numeric only TLDs (#133, pull request courtesy jmeridth) +- Allow for idna encoded domains (#133, pull request courtesy jmeridth) + + +0.14.0 (2019-08-21) +^^^^^^^^^^^^^^^^^^^ + +- Added new validators ``ipv4_cidr``, ``ipv6_cidr`` (#117, pull request courtesy woodruffw) + + +0.13.0 (2019-05-20) +^^^^^^^^^^^^^^^^^^^ + +- Added new validator: ``es_doi``, ``es_nif``, ``es_cif``, ``es_nie`` (#121, pull request courtesy kingbuzzman) + + +0.12.6 (2019-05-08) +^^^^^^^^^^^^^^^^^^^ + +- Fixed domain validator for single character domains (#118, pull request courtesy kingbuzzman) + + +0.12.5 (2019-04-15) +^^^^^^^^^^^^^^^^^^^ + +- Fixed py37 support (#113, pull request courtesy agiletechnologist) + + 0.12.4 (2019-01-02) ^^^^^^^^^^^^^^^^^^^ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/PKG-INFO new/validators-0.14.2/PKG-INFO --- old/validators-0.12.4/PKG-INFO 2019-01-02 16:44:04.000000000 +0100 +++ new/validators-0.14.2/PKG-INFO 2020-01-24 11:01:48.000000000 +0100 @@ -1,11 +1,11 @@ Metadata-Version: 2.1 Name: validators -Version: 0.12.4 +Version: 0.14.2 Summary: Python Data Validation for Humans™. Home-page: https://github.com/kvesteri/validators Author: Konsta Vesterinen Author-email: [email protected] -License: BSD +License: MIT Description: validators ---------- @@ -15,7 +15,7 @@ Platform: any Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: BSD License +Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/docs/index.rst new/validators-0.14.2/docs/index.rst --- old/validators-0.12.4/docs/index.rst 2017-06-03 16:07:19.000000000 +0200 +++ new/validators-0.14.2/docs/index.rst 2019-05-20 09:49:33.000000000 +0200 @@ -32,7 +32,8 @@ pip install validators -Currently ``validators`` supports python versions 2.7, 3.3, 3.4, 3.5 and PyPy. +Currently ``validators`` supports python versions 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 +and PyPy. Basic validators @@ -193,6 +194,32 @@ i18n validators =============== +Spanish +------- + +.. module:: validators.i18n.es + +es_doi +^^^^^^ + +.. autofunction:: es_doi + +es_nif +^^^^^^ + +.. autofunction:: es_nif + +es_nie +^^^^^^ + +.. autofunction:: es_nie + +es_cif +^^^^^^ + +.. autofunction:: es_cif + + Finnish ------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/setup.py new/validators-0.14.2/setup.py --- old/validators-0.12.4/setup.py 2018-11-13 13:33:50.000000000 +0100 +++ new/validators-0.14.2/setup.py 2019-09-19 11:43:15.000000000 +0200 @@ -41,7 +41,7 @@ name='validators', version=get_version(), url='https://github.com/kvesteri/validators', - license='BSD', + license='MIT', author='Konsta Vesterinen', author_email='[email protected]', description='Python Data Validation for Humans™.', @@ -56,7 +56,7 @@ classifiers=[ 'Environment :: Web Environment', 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', + 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/tests/i18n/test_es.py new/validators-0.14.2/tests/i18n/test_es.py --- old/validators-0.12.4/tests/i18n/test_es.py 1970-01-01 01:00:00.000000000 +0100 +++ new/validators-0.14.2/tests/i18n/test_es.py 2019-05-20 09:49:33.000000000 +0200 @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +import pytest + +from validators import ValidationFailure +from validators.i18n.es import es_cif, es_doi, es_nie, es_nif + + [email protected](('value',), [ + ('B25162520',), + ('U4839822F',), + ('B96817697',), + ('P7067074J',), + ('Q7899705C',), + ('C75098681',), + ('G76061860',), + ('C71345375',), + ('G20558169',), + ('U5021960I',), +]) +def test_returns_true_on_valid_cif(value): + assert es_cif(value) + + [email protected](('value',), [ + ('12345',), + ('ABCDEFGHI',), + ('Z5021960I',), +]) +def test_returns_false_on_invalid_cif(value): + result = es_cif(value) + assert isinstance(result, ValidationFailure) + + [email protected](('value',), [ + ('X0095892M',), + ('X8868108K',), + ('X2911154K',), + ('Y2584969J',), + ('X7536157T',), + ('Y5840388N',), + ('Z2915723H',), + ('Y4002236C',), + ('X7750702R',), + ('Y0408759V',), +]) +def test_returns_true_on_valid_nie(value): + assert es_nie(value) + + [email protected](('value',), [ + ('K0000023T',), + ('L0000024R',), + ('M0000025W',), + ('00000026A',), + ('00000027G',), + ('00000028M',), + ('00000029Y',), + ('00000030F',), + ('00000031P',), + ('00000032D',), + ('00000033X',), + ('00000034B',), + ('00000035N',), + ('00000036J',), + ('00000037Z',), + ('00000038S',), + ('00000039Q',), + ('00000040V',), + ('00000041H',), + ('00000042L',), + ('00000043C',), + ('00000044K',), + ('00000045E',), +]) +def test_returns_true_on_valid_nif(value): + assert es_nif(value) + + [email protected](('value',), [ + ('12345',), + ('X0000000T',), + ('00000000T',), + ('00000001R',), +]) +def test_returns_false_on_invalid_nif(value): + result = es_nif(value) + assert isinstance(result, ValidationFailure) + + [email protected](('value',), [ + # CIFs + ('B25162520',), + ('U4839822F',), + ('B96817697',), + # NIEs + ('X0095892M',), + ('X8868108K',), + ('X2911154K',), + # NIFs + ('26643189N',), + ('07060225F',), + ('49166693F',), +]) +def test_returns_true_on_valid_doi(value): + assert es_doi(value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/tests/i18n/test_fi.py new/validators-0.14.2/tests/i18n/test_fi.py --- old/validators-0.12.4/tests/i18n/test_fi.py 2018-11-13 13:11:17.000000000 +0100 +++ new/validators-0.14.2/tests/i18n/test_fi.py 2019-05-20 09:49:33.000000000 +0200 @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- import pytest -from validators import fi_business_id, fi_ssn, ValidationFailure +from validators import ValidationFailure +from validators.i18n.fi import fi_business_id, fi_ssn @pytest.mark.parametrize(('value',), [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/tests/test_domain.py new/validators-0.14.2/tests/test_domain.py --- old/validators-0.12.4/tests/test_domain.py 2018-06-03 12:00:00.000000000 +0200 +++ new/validators-0.14.2/tests/test_domain.py 2020-01-24 10:56:27.000000000 +0100 @@ -9,8 +9,14 @@ 'xn----gtbspbbmkef.xn--p1ai', 'underscore_subdomain.example.com', 'something.versicherung', + 'someThing.versicherung', '11.com', - 'somerandomexample.xn--fiqs8s' + '3.cn', + 'a.cn', + 'sub1.sub2.sample.co.uk', + 'somerandomexample.xn--fiqs8s', + 'kräuter.com', + 'über.com' ]) def test_returns_true_on_valid_domain(value): assert domain(value) @@ -22,8 +28,15 @@ 'example.-com', 'example.', '-example.com', + 'example-.com', + '_example.com', + 'example_.com', 'example', - 'a......b.com' + 'a......b.com', + 'a.123', + '123.123', + '123.123.123', + '123.123.123.123' ]) def test_returns_failed_validation_on_invalid_domain(value): assert isinstance(domain(value), ValidationFailure) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/tests/test_ipv4_cidr.py new/validators-0.14.2/tests/test_ipv4_cidr.py --- old/validators-0.12.4/tests/test_ipv4_cidr.py 1970-01-01 01:00:00.000000000 +0100 +++ new/validators-0.14.2/tests/test_ipv4_cidr.py 2019-08-21 09:48:18.000000000 +0200 @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +import pytest + +from validators import ipv4_cidr, ipv6_cidr, ValidationFailure + + [email protected](('cidr',), [ + ('127.0.0.1/0',), + ('123.5.77.88/8',), + ('12.12.12.12/32',), +]) +def test_returns_true_on_valid_ipv4_cidr(cidr): + assert ipv4_cidr(cidr) + assert not ipv6_cidr(cidr) + + [email protected](('cidr',), [ + ('abc.0.0.1',), + ('1.1.1.1',), + ('1.1.1.1/-1',), + ('1.1.1.1/33',), + ('1.1.1.1/foo',), +]) +def test_returns_failed_validation_on_invalid_ipv4_cidr(cidr): + assert isinstance(ipv4_cidr(cidr), ValidationFailure) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/tests/test_ipv6_cidr.py new/validators-0.14.2/tests/test_ipv6_cidr.py --- old/validators-0.12.4/tests/test_ipv6_cidr.py 1970-01-01 01:00:00.000000000 +0100 +++ new/validators-0.14.2/tests/test_ipv6_cidr.py 2019-08-21 09:48:18.000000000 +0200 @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import pytest + +from validators import ipv4_cidr, ipv6_cidr, ValidationFailure + + [email protected](('cidr',), [ + ('::1/0',), + ('dead:beef:0:0:0:0:42:1/8',), + ('abcd:ef::42:1/32',), + ('0:0:0:0:0:ffff:1.2.3.4/64',), + ('::192.168.30.2/128',), +]) +def test_returns_true_on_valid_ipv6_cidr(cidr): + assert ipv6_cidr(cidr) + assert not ipv4_cidr(cidr) + + [email protected](('cidr',), [ + ('abc.0.0.1',), + ('abcd:1234::123::1',), + ('1:2:3:4:5:6:7:8:9',), + ('abcd::1ffff',), + ('1.1.1.1',), + ('::1',), + ('::1/129',), + ('::1/-1',), + ('::1/foo',), +]) +def test_returns_failed_validation_on_invalid_ipv6_cidr(cidr): + assert isinstance(ipv6_cidr(cidr), ValidationFailure) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators/__init__.py new/validators-0.14.2/validators/__init__.py --- old/validators-0.12.4/validators/__init__.py 2019-01-02 16:38:55.000000000 +0100 +++ new/validators-0.14.2/validators/__init__.py 2020-01-24 10:58:09.000000000 +0100 @@ -1,17 +1,22 @@ -from .between import between # noqa -from .domain import domain # noqa -from .email import email # noqa -from .extremes import Max, Min # noqa -from .hashes import md5, sha1, sha224, sha256, sha512 # noqa -from .i18n import fi_business_id, fi_ssn # noqa -from .iban import iban # noqa -from .ip_address import ipv4, ipv6 # noqa -from .length import length # noqa -from .mac_address import mac_address # noqa -from .slug import slug # noqa -from .truthy import truthy # noqa -from .url import url # noqa -from .utils import ValidationFailure, validator # noqa -from .uuid import uuid # noqa +from .between import between +from .domain import domain +from .email import email +from .extremes import Max, Min +from .hashes import md5, sha1, sha224, sha256, sha512 +from .i18n import fi_business_id, fi_ssn +from .iban import iban +from .ip_address import ipv4, ipv4_cidr, ipv6, ipv6_cidr +from .length import length +from .mac_address import mac_address +from .slug import slug +from .truthy import truthy +from .url import url +from .utils import ValidationFailure, validator +from .uuid import uuid -__version__ = '0.12.4' +__all__ = ('between', 'domain', 'email', 'Max', 'Min', 'md5', 'sha1', 'sha224', + 'sha256', 'sha512', 'fi_business_id', 'fi_ssn', 'iban', 'ipv4', + 'ipv4_cidr', 'ipv6', 'ipv6_cidr', 'length', 'mac_address', 'slug', + 'truthy', 'url', 'ValidationFailure', 'validator', 'uuid') + +__version__ = '0.14.2' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators/domain.py new/validators-0.14.2/validators/domain.py --- old/validators-0.12.4/validators/domain.py 2018-06-03 12:00:00.000000000 +0200 +++ new/validators-0.14.2/validators/domain.py 2020-01-24 10:56:27.000000000 +0100 @@ -1,15 +1,31 @@ import re +import six + from .utils import validator +if six.PY3: + text_type = str + unicode = str +else: + text_type = unicode + pattern = re.compile( - r'^(:?(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|' # domain pt.1 - r'([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|' # domain pt.2 - r'([a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]))\.)+' # domain pt.3 - r'([a-zA-Z]{2,13}|(xn--[a-zA-Z0-9]{2,30}))$' # TLD + r'^(?:[a-zA-Z0-9]' # First character of the domain + r'(?:[a-zA-Z0-9-_]{0,61}[A-Za-z0-9])?\.)' # Sub domain + hostname + r'+[A-Za-z0-9][A-Za-z0-9-_]{0,61}' # First 61 characters of the gTLD + r'[A-Za-z]$' # Last character of the gTLD ) +def to_unicode(obj, charset='utf-8', errors='strict'): + if obj is None: + return None + if not isinstance(obj, bytes): + return text_type(obj) + return obj.decode(charset, errors) + + @validator def domain(value): """ @@ -40,4 +56,7 @@ :param value: domain string to validate """ - return pattern.match(value) + try: + return pattern.match(to_unicode(value).encode('idna').decode('ascii')) + except UnicodeError: + return False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators/i18n/__init__.py new/validators-0.14.2/validators/i18n/__init__.py --- old/validators-0.12.4/validators/i18n/__init__.py 2015-10-10 08:47:54.000000000 +0200 +++ new/validators-0.14.2/validators/i18n/__init__.py 2019-05-20 09:49:33.000000000 +0200 @@ -1 +1,4 @@ +# TODO: remove, let the user import it if they really want it from .fi import fi_business_id, fi_ssn # noqa + +__all__ = ('fi_business_id', 'fi_ssn') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators/i18n/es.py new/validators-0.14.2/validators/i18n/es.py --- old/validators-0.12.4/validators/i18n/es.py 1970-01-01 01:00:00.000000000 +0100 +++ new/validators-0.14.2/validators/i18n/es.py 2019-05-20 09:49:33.000000000 +0200 @@ -0,0 +1,200 @@ +# -*- coding: utf-8 -*- +from validators.utils import validator + +__all__ = ('es_cif', 'es_nif', 'es_nie', 'es_doi',) + + +def nif_nie_validation(doi, number_by_letter, special_cases): + """ + Validate if the doi is a NIF or a NIE. + :param doi: DOI to validate. + :return: boolean if it's valid. + """ + doi = doi.upper() + if doi in special_cases: + return False + + table = 'TRWAGMYFPDXBNJZSQVHLCKE' + + if len(doi) != 9: + return False + + control = doi[8] + + # If it is not a DNI, convert the first letter to the corresponding + # digit + numbers = number_by_letter.get(doi[0], doi[0]) + doi[1:8] + + return numbers.isdigit() and control == table[int(numbers) % 23] + + +@validator +def es_cif(doi): + """ + Validate a Spanish CIF. + + Each company in Spain prior to 2008 had a distinct CIF and has been + discontinued. For more information see `wikipedia.org/cif`_. + + The new replacement is to use NIF for absolutely everything. The issue is + that there are "types" of NIFs now: company, person[citizen vs recident] + all distinguished by the first character of the DOI. For this reason we + will continue to call CIF NIFs that are used for companies. + + This validator is based on `generadordni.es`_. + + .. _generadordni.es: + https://generadordni.es/ + + .. _wikipedia.org/cif: + https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal + + Examples:: + + >>> es_cif('B25162520') + True + + >>> es_cif('B25162529') + ValidationFailure(func=es_cif, args=...) + + .. versionadded:: 0.13.0 + + :param doi: DOI to validate + """ + doi = doi.upper() + + if len(doi) != 9: + return False + + table = 'JABCDEFGHI' + first_chr = doi[0] + doi_body = doi[1:8] + control = doi[8] + + if not doi_body.isdigit(): + return False + + odd_result = 0 + even_result = 0 + for index, char in enumerate(doi_body): + if index % 2 == 0: + # Multiply each each odd position doi digit by 2 and sum it all + # together + odd_result += sum(map(int, str(int(char) * 2))) + else: + even_result += int(char) + + res = (10 - (even_result + odd_result) % 10) % 10 + + if first_chr in 'ABEH': # Number type + return str(res) == control + elif first_chr in 'PSQW': # Letter type + return table[res] == control + elif first_chr not in 'CDFGJNRUV': + return False + + return control == str(res) or control == table[res] + + +@validator +def es_nif(doi): + """ + Validate a Spanish NIF. + + Each entity, be it person or company in Spain has a distinct NIF. Since + we've designated CIF to be a company NIF, this NIF is only for person. + For more information see `wikipedia.org/nif`_. + + This validator is based on `generadordni.es`_. + + .. _generadordni.es: + https://generadordni.es/ + + .. _wikipedia.org/nif: + https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal + + Examples:: + + >>> es_nif('26643189N') + True + + >>> es_nif('26643189X') + ValidationFailure(func=es_nif, args=...) + + .. versionadded:: 0.13.0 + + :param doi: DOI to validate + """ + number_by_letter = {'L': '0', 'M': '0', 'K': '0'} + special_cases = ['X0000000T', '00000000T', '00000001R'] + return nif_nie_validation(doi, number_by_letter, special_cases) + + +@validator +def es_nie(doi): + """ + Validate a Spanish NIE. + + The NIE is a tax identification number in Spain, known in Spanish as the + NIE, or more formally the Número de identidad de extranjero. For more + information see `wikipedia.org/nie`_. + + This validator is based on `generadordni.es`_. + + .. _generadordni.es: + https://generadordni.es/ + + .. _wikipedia.org/nie: + https://es.wikipedia.org/wiki/N%C3%BAmero_de_identidad_de_extranjero + + Examples:: + + >>> es_nie('X0095892M') + True + + >>> es_nie('X0095892X') + ValidationFailure(func=es_nie, args=...) + + .. versionadded:: 0.13.0 + + :param doi: DOI to validate + """ + number_by_letter = {'X': '0', 'Y': '1', 'Z': '2'} + special_cases = ['X0000000T'] + + # NIE must must start with X Y or Z + if not doi or doi[0] not in number_by_letter.keys(): + return False + + return nif_nie_validation(doi, number_by_letter, special_cases) + + +@validator +def es_doi(doi): + """ + Validate a Spanish DOI. + + A DOI in spain is all NIF / CIF / NIE / DNI -- a digital ID. For more + information see `wikipedia.org/doi`_. + + This validator is based on `generadordni.es`_. + + .. _generadordni.es: + https://generadordni.es/ + + .. _wikipedia.org/doi: + https://es.wikipedia.org/wiki/Identificador_de_objeto_digital + + Examples:: + + >>> es_doi('X0095892M') + True + + >>> es_doi('X0095892X') + ValidationFailure(func=es_doi, args=...) + + .. versionadded:: 0.13.0 + + :param doi: DOI to validate + """ + return es_nie(doi) or es_nif(doi) or es_cif(doi) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators/ip_address.py new/validators-0.14.2/validators/ip_address.py --- old/validators-0.12.4/validators/ip_address.py 2018-06-03 11:52:26.000000000 +0200 +++ new/validators-0.14.2/validators/ip_address.py 2019-08-21 09:48:18.000000000 +0200 @@ -30,6 +30,31 @@ @validator +def ipv4_cidr(value): + """ + Return whether or not given value is a valid CIDR-notated IP version 4 + address range. + + This validator is based on RFC4632 3.1. + + Examples:: + + >>> ipv4_cidr('1.1.1.1/8') + True + + >>> ipv4_cidr('1.1.1.1') + ValidationFailure(func=ipv4_cidr, args={'value': '1.1.1.1'}) + """ + try: + prefix, suffix = value.split('/', 2) + except ValueError: + return False + if not ipv4(prefix) or not suffix.isdigit(): + return False + return 0 <= int(suffix) <= 32 + + +@validator def ipv6(value): """ Return whether or not given value is a valid IP version 6 address @@ -92,3 +117,28 @@ elif count_blank == 2 and not ipv6_groups[0] and not ipv6_groups[1]: return True return False + + +@validator +def ipv6_cidr(value): + """ + Returns whether or not given value is a valid CIDR-notated IP version 6 + address range. + + This validator is based on RFC4632 3.1. + + Examples:: + + >>> ipv6_cidr('::1/128') + True + + >>> ipv6_cidr('::1') + ValidationFailure(func=ipv6_cidr, args={'value': '::1'}) + """ + try: + prefix, suffix = value.split('/', 2) + except ValueError: + return False + if not ipv6(prefix) or not suffix.isdigit(): + return False + return 0 <= int(suffix) <= 128 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators/utils.py new/validators-0.14.2/validators/utils.py --- old/validators-0.12.4/validators/utils.py 2019-01-02 16:37:15.000000000 +0100 +++ new/validators-0.14.2/validators/utils.py 2019-04-15 13:20:22.000000000 +0200 @@ -6,7 +6,7 @@ from decorator import decorator -class ValidationFailure(object): +class ValidationFailure(Exception): def __init__(self, func, args): self.func = func self.__dict__.update(args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators.egg-info/PKG-INFO new/validators-0.14.2/validators.egg-info/PKG-INFO --- old/validators-0.12.4/validators.egg-info/PKG-INFO 2019-01-02 16:44:04.000000000 +0100 +++ new/validators-0.14.2/validators.egg-info/PKG-INFO 2020-01-24 11:01:48.000000000 +0100 @@ -1,11 +1,11 @@ Metadata-Version: 2.1 Name: validators -Version: 0.12.4 +Version: 0.14.2 Summary: Python Data Validation for Humans™. Home-page: https://github.com/kvesteri/validators Author: Konsta Vesterinen Author-email: [email protected] -License: BSD +License: MIT Description: validators ---------- @@ -15,7 +15,7 @@ Platform: any Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: BSD License +Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/validators-0.12.4/validators.egg-info/SOURCES.txt new/validators-0.14.2/validators.egg-info/SOURCES.txt --- old/validators-0.12.4/validators.egg-info/SOURCES.txt 2019-01-02 16:44:04.000000000 +0100 +++ new/validators-0.14.2/validators.egg-info/SOURCES.txt 2020-01-24 11:01:48.000000000 +0100 @@ -14,7 +14,9 @@ tests/test_extremes.py tests/test_iban.py tests/test_ipv4.py +tests/test_ipv4_cidr.py tests/test_ipv6.py +tests/test_ipv6_cidr.py tests/test_length.py tests/test_mac_address.py tests/test_md5.py @@ -27,6 +29,7 @@ tests/test_uuid.py tests/test_validation_failure.py tests/i18n/__init__.py +tests/i18n/test_es.py tests/i18n/test_fi.py validators/__init__.py validators/between.py @@ -50,4 +53,5 @@ validators.egg-info/requires.txt validators.egg-info/top_level.txt validators/i18n/__init__.py +validators/i18n/es.py validators/i18n/fi.py \ No newline at end of file
