mfbddlmZddlmZddlmZddlmZmZddlZddlm Z ddl m Z ddl m Z mZmZmZmZmZmZmZdd lmZmZmZmZdd lmZmZmZe jZd Z Gd d e!Z"Gdde!Z#Gdde$Z%dZ&Gdde'Z(e(de%fiZ)dS))absolute_import) literal_eval)copy)datedatetimeN)warn)errors) _int_types _str_type ContainerHashableIterableMappingSequenceSized)schema_registryrules_set_registryDefinitionSchema SchemaError)drop_item_from_tuplereadonly_classpropertyTypeDefinitioncd}|}||_|S)Nc td)NzcDummy method called. Its purpose is to hold justvalidation constraints for a rule in its docstring.) RuntimeError)self constraintfieldvalues I/opt/imunify360/venv/lib64/python3.11/site-packages/cerberus/validator.pydummyz(dummy_for_rule_validation..dummy s    )__doc__)rule_constraintsr!fs r dummy_for_rule_validationr&s$    A AI Hr"ceZdZdZdS) DocumentErrorzBRaised when the target document is missing or has the wrong formatN__name__ __module__ __qualname__r#r"r r(r(,sLLDr"r(ceZdZdZdS)_SchemaRuleTypeErrorzw Raised when a schema (list) validation encounters a mapping. Not supposed to be used outside this module. Nr)r-r"r r/r/2s  Dr"r/c4eZdZdZdZ dZ edeefdede fdede fe fede fded e fded efded eefded efded efe fedeefe fedefdede fdd Z eZ fdZedZdZedZdZdrdZdZdZdZdZ dZ!e"dZ#e#j$dZ#e"d Z%e%j$d!Z%e"d"Z&e"d#Z'e'j$d$Z'e"d%Z(e"d&Z)e)j$d'Z)e"d(Z*e*j$d)Z*e"d*Z+e+j$d+Z+e"d,Z,e"d-Z-e"d.Z.e"d/Z/e/j$d0Z/e"d1Z0e"d2Z1e1j$d3Z1e"d4Z2e2j$d5Z2e3d6Z4dsd7Z5d8Z6dtd:Z7d;Z8d<Z9d=Z:d>Z;d?ZdBZ?dCZ@edDZAedEZBdFZCdGZDdHZEdIZFdJZGdKZHdLZIdudNZJeJZKdOZLdPZMdQZNeOdRZPdSZQdTZRdUZSdVZTdWZUdXZVdYZWdZZXd[ZYd\ZZd]Z[d^Z\d_Z]d`Z^daZ_dbZ`dcZaddZbeOdeZcdfZddgZedhZfdiZgdjZheOdkZieOdkZjdlZkdmZldnZmdoZndpZodqZpxZqS)v BareValidatora Validator class. Normalizes and/or validates any mapping against a validation-schema which is provided as an argument at class instantiation or upon calling the :meth:`~cerberus.Validator.validate`, :meth:`~cerberus.Validator.validated` or :meth:`~cerberus.Validator.normalized` method. An instance itself is callable and executes a validation. All instantiation parameters are optional. There are the introspective properties :attr:`types`, :attr:`validators`, :attr:`coercers`, :attr:`default_setters`, :attr:`rules`, :attr:`normalization_rules` and :attr:`validation_rules`. The attributes reflecting the available rules are assembled considering constraints that are defined in the docstrings of rules' methods and is effectively used as validation schema for :attr:`schema`. :param schema: See :attr:`~cerberus.Validator.schema`. Defaults to :obj:`None`. :type schema: any :term:`mapping` :param ignore_none_values: See :attr:`~cerberus.Validator.ignore_none_values`. Defaults to ``False``. :type ignore_none_values: :class:`bool` :param allow_unknown: See :attr:`~cerberus.Validator.allow_unknown`. Defaults to ``False``. :type allow_unknown: :class:`bool` or any :term:`mapping` :param require_all: See :attr:`~cerberus.Validator.require_all`. Defaults to ``False``. :type require_all: :class:`bool` :param purge_unknown: See :attr:`~cerberus.Validator.purge_unknown`. Defaults to to ``False``. :type purge_unknown: :class:`bool` :param purge_readonly: Removes all fields that are defined as ``readonly`` in the normalization phase. :type purge_readonly: :class:`bool` :param error_handler: The error handler that formats the result of :attr:`~cerberus.Validator.errors`. When given as two-value tuple with an error-handler class and a dictionary, the latter is passed to the initialization of the error handler. Default: :class:`~cerberus.errors.BasicErrorHandler`. :type error_handler: class or instance based on :class:`~cerberus.errors.BaseErrorHandler` or :class:`tuple` )nullable)r2readonlytypeemptybinaryr-boolean containerrrdictfloatintegerlistnumbersetstring) r6r7r8rrr9r:r;r<r=r>r?cNd|_ tj|_ d|_ tj|_ tj|_ d|_ d|_ d|_ | ||_ ||||dd|_|dd|_|dd|_g|_ t)t*|dS)a4 The arguments will be treated as with this signature: __init__(self, schema=None, ignore_none_values=False, allow_unknown=False, require_all=False, purge_unknown=False, purge_readonly=False, error_handler=errors.BasicErrorHandler) Nr-Fschema allow_unknown require_all)documentr ErrorList_errors recent_errorDocumentErrorTreedocument_error_treeSchemaErrorTreeschema_error_tree document_path schema_pathupdate"_BareValidator__init_error_handler error_handler_BareValidator__store_configgetrArBrC_remaining_rulessuperr1__init__)rargskwargs __class__s r rUzBareValidator.__init__s/  *'))  :! @#)#;#=#=  B"(!7!9!9 @  % % !66v>> A D&)))jj400 #ZZ??!::mU;; " $ mT""++-----r"c@|dtj}t|tr|\}}ni}t|t r"t |tjr|di|St|tjr|Std)NrPzInvalid error_handler.r-) popr BasicErrorHandler isinstancetupler4 issubclassBaseErrorHandlerr)rWrP eh_configs r __init_error_handlerz"BareValidator.__init_error_handlers ?F4LMM mU + + '4 $M99I mT * * 9z 620 0  9!=--9-- -  v'> ? ? 9 788 8r"cd}t|dt|D]&\}}||vrtd|z||||<'||_dS)z.Assign args to kwargs and store configuration.)rAignore_none_valuesrBrC purge_unknownpurge_readonlyNz.__init__ got multiple values for argument '%s') enumeratelen TypeError_config)rrVrW signatureips r __store_configzBareValidator.__store_configss i #d)) 455 $ $DAqF{{ SVW WXXX Gq   # #r"c8|jdS)z'Purge the cache of known valid schemas.N)_valid_schemasclear)clss r clear_cacheszBareValidator.clear_cachess   """""r"c t|dkr|j|d|j|dD]P}|j||j||j|QdSt|dkrJt|dtr/| |dtj |ddSt|dkr7|d}|dj}|dj}|dd}|j|fz}|j}|tjjkr ||||fz }|sd} n|||j|} |dkr| |d} n0|dkr"| ||j} || vrd}n| |} |j|} tj||||| | ||_| |jgdSdS) a Creates and adds one or multiple errors. :param args: Accepts different argument's signatures. *1. Bulk addition of errors:* - :term:`iterable` of :class:`~cerberus.errors.ValidationError`-instances The errors will be added to :attr:`~cerberus.Validator._errors`. *2. Custom error:* - the invalid field's name - the error message A custom error containing the message will be created and added to :attr:`~cerberus.Validator._errors`. There will however be fewer information contained in the error (no reference to the violated rule and its constraint). *3. Defined error:* - the invalid field's name - the error-reference, see :mod:`cerberus.errors` - arbitrary, supplemental information about the error A :class:`~cerberus.errors.ValidationError` instance will be created and added to :attr:`~cerberus.Validator._errors`. rNr2Frequired__require_all__)rgrFextendsortrIaddrKrPemitr\r _errorr CUSTOMcoderulerLrM UNKNOWN_FIELD_resolve_rules_set_resolve_schemarArRrCrDValidationErrorrG) rrVerrorrr~rinforLrMr rules_setrs r r|zBareValidator._errors`L t99>> L  Q ( ( ( L     a / /(,,U333&**5111"''.... / /YY!^^ 47I > >^ KKQQ 8 8 8 8 8 YY!^^GE7O ) )ne44 3"0!2,0,>,OO )  *.*:O ' 'lE22 / , *.*:\*IO 'r"cd||dd}t||d}|#td|||S)Nz_{0}_{1} _z/There's no handler for '{}' in the '{}' domain.)formatreplacegetattrr)rdomainr methodnameresults r __get_rule_handlerz BareValidator.__get_rule_handlerjsh&&vt||C/E/EFF z400 > &v..  r"cjt|j}t|j}|D]}t|dD]}t |j||z|_ t|dD]}t |j||z|_ |jr||j||dS)a{ Removes nodes by index from an errorpath, relatively to the basepaths of self. :param errors: A list of :class:`errors.ValidationError` instances. :param dp_items: A list of integers, pointing at the nodes to drop from the :attr:`document_path`. :param sp_items: Alike ``dp_items``, but for :attr:`schema_path`. T)reverseN)rgrLrMsortedr child_errors_drop_nodes_from_errorpaths)rrFdp_itemssp_items dp_basedepth sp_basedepthrrks r rz)BareValidator._drop_nodes_from_errorpathsts4-.. 4+,,  Y YEHd333  &:')9''##Hd333  $8%|a'7%%!!! Y001CXxXXX Y Yr"c|dr.|dd}|dr|jn|j}n|j}|d}|D]}||vrdS||i} |d|fS)a Searches for a field as defined by path. This method is used by the ``dependency`` evaluation logic. :param path: Path elements are separated by a ``.``. A leading ``^`` indicates that the path relates to the document root, otherwise it relates to the currently evaluated document, which is possibly a subdocument. The sequence ``^^`` at the start will be interpreted as a literal ``^``. :type path: :class:`str` :returns: Either the found field name and its value or :obj:`None` for both. :rtype: A two-value :class:`tuple`. ^rtN.NN) startswithrDrsplitrR)rpathcontextpartsparts r _lookup_fieldzBareValidator._lookup_fields ??3   $8D'+s';';SdmmASGGmG 3 , ,D7""!zzkk$++GGRy'!!r"ct|tr|St|tr|j|SdSN)r\rr rrR)rrs r rz BareValidator._resolve_rules_setsH i ) ) :   9 - - :*..y99 9tr"ct|tr|St|tr|j|SdSr)r\rr rrRrrAs r rzBareValidator._resolve_schemasG fg & & 4M  * * 4'++F33 3tr"c8|jddS)a2 If ``True`` unknown fields that are not defined in the schema will be ignored. If a mapping with a validation schema is given, any undefined field will be validated against its rules. Also see :ref:`allowing-the-unknown`. Type: :class:`bool` or any :term:`mapping` rBFrirRrs r rBzBareValidator.allow_unknown|777r"c|js.t|ttfst|d|i||jd<dS)NrB)rr\boolrrirrs r rBzBareValidator.allow_unknownsJ  =ED:J3K!L!L = TOU#; < < <(- _%%%r"c8|jddS)zw If ``True`` known fields that are defined in the schema will be required. Type: :class:`bool` rCFrrs r rCzBareValidator.require_alls | u555r"c||jd<dS)NrCrirs r rCzBareValidator.require_alls&+ ]###r"c6||jS)z The errors of the last processing formatted by the handler that is bound to :attr:`~cerberus.Validator.error_handler`. )rPrFrs r r zBareValidator.errorss !!$,///r"c8|jddS)zm Whether to not process :obj:`None`-values in a document or not. Type: :class:`bool` rcFrrs r rcz BareValidator.ignore_none_valuess | 4e<<DLLL ] :j1ABB :!DLLL+D&99DLLLr"cB|jdtS)zg The registry that holds referenced schemas. Type: :class:`~cerberus.Registry` r)rirRrrs r rzBareValidator.schema_registryTs | 1?CCCr"c||jd<dS)Nrrrs r rzBareValidator.schema_registry\s*2 &'''r"ct|jt|jz}|rtd|zt |j|jzS)zi The constraints that can be used for the 'type' rule. Type: A tuple of strings. zcThese types are defined both with a method and in the'types_mapping' property of this validator: %s)r> types_mapping_types_from_methodsrr])rqredundant_typess r typeszBareValidator.typesbsh c/003s7N3O3OO   ACRS    S&''#*AAAr"ctj|_d|_tj|_tj|_t||_ |j sd|_ |t|||_ nB|j ;t|jt ri|_nt%tj|t)tjt|t s,t)tj||j|dSNF)r rErFrGrHrIrJrKrrDrrrrAr\rBrrrSCHEMA_ERROR_MISSINGr(DOCUMENT_MISSINGDOCUMENT_FORMATrrPstart)rrDrAs r __init_processingzBareValidator.__init_processingss'))  #)#;#=#= !'!7!9!9X } ("'D   *488DKK [ $,g66 ?! !&"=>>>   788 8(G,, I 6 = =h G GHH H   &&&&&r"c||r2|D]-} |j|#t$rY*wxYwdSg|_dS)z Drops rules from the queue of the rules that still need to be evaluated for the currently processed field. If no arguments are given, the whole queue is emptied. N)rSremove ValueError)rrulesrs r _drop_remaining_rulesz#BareValidator._drop_remaining_rulesst  '  )006666!D   %'D ! ! !s # 00Fc|||||j|j|j||jr|sdS|jS)a Returns the document normalized according to the specified rules of a schema. :param document: The document to normalize. :type document: any :term:`mapping` :param schema: The validation schema. Defaults to :obj:`None`. If not provided here, the schema must have been provided at class instantiation. :type schema: any :term:`mapping` :param always_return_document: Return the document, even if an error occurred. Defaults to: ``False``. :type always_return_document: :class:`bool` :return: A normalized copy of the provided mapping or :obj:`None` if an error occurred during normalization. N)_BareValidator__init_processing!_BareValidator__normalize_mappingrDrArPendrF)rrDrAalways_return_documents r normalizedzBareValidator.normalizedsj x000    <<< t$$$ < ! 6 !4= r"c4t|tr||}|}|D] }|||||<!||||jr|js||||j r| ||| ||| ||| |||||d|_|S)NT)r\r rrr'_BareValidator__normalize_rename_fieldsrdrB_normalize_purge_unknownre(_BareValidator__normalize_purge_readonly(_BareValidator__validate_readonly_fields(_BareValidator__normalize_default_fields_normalize_coerce$_BareValidator__normalize_containersrrmappingrArs r __normalize_mappingz!BareValidator.__normalize_mappings+ fi ( ( 2))&11F C CE 33F5MBBF5MM &&w777   ;d&8 ;  ) )'6 : : :   =  + +GV < < < ''888 ''888 w/// ##GV444"r"c tj}|D]}||vrSd||vrI|||d|||||dd|||<Yt |jt rOd|jvrF||jd||||jdd|||<dS) {'oneof': [ {'type': 'callable'}, {'type': 'list', 'schema': {'oneof': [{'type': 'callable'}, {'type': 'string'}]}}, {'type': 'string'} ]} coercer2FN)r COERCION_FAILED _BareValidator__normalize_coercerRr\rBr)rrrArrs r rzBareValidator._normalize_coerces&  E8ve}#<#rRr\r/_BareValidator__normalize_mapping_per_keysrules1_BareValidator__normalize_mapping_per_valuesrulesrB,_BareValidator__normalize_mapping_per_schemar/r r-_BareValidator__normalize_sequence_per_schema,_BareValidator__normalize_sequence_per_items)rrrArrs r __normalize_containersz$BareValidator.__normalize_containerss P PE 5"--..E'%.'22 P%''::wu k(B!E))<<wu m(D3@ 2G<<;;E7FSSSS/ GENI66 PGENH55 Pu$$88PPPP%%77wOOO9 P Ps?C C$#C$c tfd||D}td||D}|||df|}||d}|jr8||jgddg||j|D]}|||kr||||vrht d d d |j |fzD| |||||||<|||||||<|||=dS) Nc3 K|]}|fV dSrr-).0kproperty_ruless r zBBareValidator.__normalize_mapping_per_keysrules..!s(CCq>*CCCCCCr"c3K|]}||fV dSrr-rrs r rzBBareValidator.__normalize_mapping_per_keysrules.."s&88A!Q888888r"r rrrATrruzHNormalizing keys of {path}: {key} already exists, its value is replaced.rc34K|]}t|VdSr)rrxs r rzBBareValidator.__normalize_mapping_per_keysrules..1s(%T%Tc!ff%T%T%T%T%T%Tr")rkey) r9rrrFrr|rrjoinrL) rrrrrArD validatorrrs ` r !__normalize_mapping_per_keysrulesz/BareValidator.__normalize_mapping_per_keysrules sCCCCGENCCCDD8888899-- {/CF.  %%ht%LL   +  , ,Y->QF K K K KK ) * * * & &AF1I~~ayGEN**--3V XX%T%Td6HE86S%T%T%TTT.4..-4EN1,=vay)),3EN1,=vay)EN1%% & &r"c>tfd||D}|||df|}|||d||<|jr9||jgdg||jdSdS)Nc3 K|]}|fV dSrr-)rr value_ruless r rzDBareValidator.__normalize_mapping_per_valuesrules..;s(@@A;'@@@@@@r"r rTrru)r9rrrFrr|)rrrr'rAr#s ` r #__normalize_mapping_per_valuesrulesz1BareValidator.__normalize_mapping_per_valuesrules:s@@@@@@@AA-- }/Ef.  #-- EN4.     +  , ,Y->QC H H H KK ) * * * * * + +r"c 6||i}|s!t|jtr|j}|||df|di|d|j|d|j|d|j}t||}|||d}||||<|j r| |j dSdS)NrArBrdrC)rrrArBrdrCTr) rRr\rBrrrdrCr4rrFr|)rrrrArr# value_type result_values r __normalize_mapping_per_schemaz,BareValidator.__normalize_mapping_per_schemaFs 5"%% 'D$6@@ '&E-- *99Xr**))OT5GHH))OT5GHH -1ABB .  '%.))  ++GENSW+XX #L11   + KK ) * * * * * + +r"c &tfdtt|Dtdt|D}|df}t |}||d}|||<|jr9| |jgdg| |jdSdS)Nc38K|]}|dfVdS)rANr-)rrrrAs r rz@BareValidator.__normalize_sequence_per_schema..Zs1 N Naax( ) N N N N N Nr"c3$K|] \}}||fV dSrr-rrvs r rz@BareValidator.__normalize_sequence_per_schema..\s*EE41aAEEEEEEr"rArTrru) r9rangergrfrr4rvaluesrFrr|)rrrrArDr#r*rs ` ` r __normalize_sequence_per_schemaz-BareValidator.__normalize_sequence_per_schemaXs$ N N N N N5WU^9L9L3M3M N N N  EE9WU^+D+DEEEEE-- x/@.  '%.)) %%ht%LL#FMMOO44   +  , ,Y->QC H H H KK ) * * * * * + +r"cZ||d||}}t|t|krdStdt|D}tdt|D}|||df|}t ||}||d} || ||<|jr9||jgdg| |jdSdS)Nr c3$K|] \}}||fV dSrr-r0s r rz?BareValidator.__normalize_sequence_per_items..ks*;;$!Q1v;;;;;;r"c3$K|] \}}||fV dSrr-r0s r rz?BareValidator.__normalize_sequence_per_items..ls*==41aA======r"rTrru) rgr9rfrr4rr3rFrr|) rrrrArr3rDr#r*rs r __normalize_sequence_per_itemsz,BareValidator.__normalize_sequence_per_itemsgs5u g.v u::V $ $ F;;)E*:*:;;;<<==9V+<+<=====-- w/?.  '%.)) %%ht%LL#FMMOO44   +  , ,Y->QC H H H KK ) * * * * * + +r"cTfd|DD]}|||S)Nchg|].}|idd,|/S)r3FrRrr rAs r z.ys<UUUAFJJq",=,=,A,A*e,T,TUaUUUr"rZrrArs ` r __normalize_purge_readonlyz(BareValidator.__normalize_purge_readonlyws@UUUUUUU  E KK    r"cTfd|DD]}|||S){'type': 'boolean'}cg|]}|v| Sr-r-r<s r r=z:BareValidator._normalize_purge_unknown..s<<r?s ` r rz&BareValidator._normalize_purge_unknown}sB=<<<<<<  E KK    r"ct|D]v}||vr/||||||||5t|jt r'd|jvr||||ji|w|S)Nrename_handler)r]_normalize_rename_normalize_rename_handlerr\rBrrs r __normalize_rename_fieldsz'BareValidator.__normalize_rename_fieldss7^^  E&&w>>>..wFFFF4-w77 $(:::..eT%78%r"cRd||vr|||||d<||=dSdS)z{'type': 'hashable'}renameNr-rs r rFzBareValidator._normalize_renames; ve} $ $/6u~GF5M(+ , % $r"cd||vrdS|||d||dtj}||kr||||<||=dSdS)rrENF)rr RENAMING_FAILED)rrrArnew_names r rGz'BareValidator._normalize_rename_handlerss 6%= 0 0 F** 5M* +UE5&BX   u   'GH   r"cfdDD]+}|d||,dS)Nc3K|]8}|v|d4|V9dS)r3N)rrR)rr rrArs r rz;BareValidator.__validate_readonly_fields..sY  G|| 7 7q B B F Fz R R| |||  r"r3)_validate_readonlyrs``` r __validate_readonly_fieldsz(BareValidator.__validate_readonly_fieldssy          V VE  # #F5M*$=ugen U U U U  V Vr"cfdD} fd|D}n#t$rtwxYw|D]}||t}fd|D}|r|d} ||ne#t $r||YnDt$r8}| |tj t|Yd}~nd}~wwxYwtt|} | |vr(|D]#}| |tj d$dS|| |dSdS)Ncdg|],}|vs$||dd*|-S)Nr2Fr;)rr rrAs r r=z.sT    "q j%88# #""r"c(g|]}d|v |S)defaultr-r<s r r=z.s("U"U"Ui6RS9>T>T1>T>T>Tr"c(g|]}d|v |S)default_setterr-r<s r r=z.s/& & & '76!9'D'DA'D'D'Dr"rz)Circular dependencies of default setters.)rhr/_normalize_defaultr>rZ_normalize_default_setterKeyErrorappendrr|r SETTING_DEFAULT_FAILEDrhashr]rz) rrrA empty_fieldsfields_with_defaultrknown_fields_statesfields_with_default_setterrfields_processing_states `` r __normalize_default_fieldsz(BareValidator.__normalize_default_fieldss'         '"U"U"U"Ul"U"U"U   ' ' '& & '( < _unrequired_by_excludesrrrDrArcrR$_BareValidator__validate_definitions'_BareValidator__validate_unknown_fields(_BareValidator__validate_required_fieldsrPrrrF)rrDrArN normalizer definitionss r validatezBareValidator.validates& '*uu$ x000  A  $ $T]DK @ @ @] 6 6E& 4=+?+G+//%00K&++K????..u5555{ ;  + +DM : : : t$$$ %%%%r"cl|dd}|j|i||jr|sdS|jS)z Wrapper around :meth:`~cerberus.Validator.validate` that returns the normalized and validated document or :obj:`None` if validation failed. rFN)rZrorFrD)rrVrWrs r validatedzBareValidator.validatedsO "(,De!L!L t&v&&& < ! 6 !4= r"c`|jr|j|}t|jttfrT|jrdnd}||||ji}|||ids||jdSdSdS||tj dS)NrB__allow_unknown__)rrAFrm) rBrDr\rr rrr|rFr r)rrrrr#s r __validate_unknown_fieldsz'BareValidator.__validate_unknown_fields)s   5M%(E$,w .BCC 337-XEX  55!-ud>P6Q6 !y%5AAA3KK 122222 3 333 KKv3 4 4 4 4 4r"cfd}jfdjDfdjDfdD_jrAjd} ||}|rnn#t$rYn wxYwjAdS)z3Validate a field's value against its defined rules.crd|}||dS)Nro)rrR)rr#rnrrrs r validate_rulez;BareValidator.__validate_definitions..validate_rule;s:// DAAI9[__T488%GG Gr"c.g|]}|vs |jv|Sr-)mandatory_validations)rr rnrs r r=z8BareValidator.__validate_definitions..Bs;   K1(B#B#B #B#B#Br"c3$K|] }|v|V dSrr-)rr  rules_queues r rz7BareValidator.__validate_definitions..Gs6  Qk5I5IA5I5I5I5I  r"c3>K|]}|vr|jvr|dv|VdS))rBrCmetarvN)normalization_rules)rr r|rs r rz7BareValidator.__validate_definitions..JsW   ##111MMM NMMM   r"rN) rrDpriority_validationsrxrzrSrZr/r)rrnrrxrrr|rs``` @@r __validate_definitionsz$BareValidator.__validate_definitions8s H H H H H H H H--k::  e$     .       1                   !,# (,,Q//D &t,,'    #  ""$$$$$s5 C CCz {'oneof': [{'type': 'boolean'}, {'type': ['dict', 'string'], 'check_with': 'bulk_schema'}]} c.t|trWt|tsBtfd|D}|r#||t j|dSdS|vr#||t j|dSdS)z{'type': 'container'}c3$K|] }|v|V dSrr-)rr allowed_valuess r rz2BareValidator._validate_allowed..ks-JJA!>2I2Ia2I2I2I2IJJr"N)r\rr r]r|r UNALLOWED_VALUESUNALLOWED_VALUE)rrrr unalloweds ` r _validate_allowedzBareValidator._validate_allowedhs eX & & Bz%/K/K BJJJJJJJJJI G E6#:IFFFFF G GN** E6#95AAAAA+*r"c|t|tra |d|}n;#t$r.|d|}t dt YnwxYw|||dSt|t r|D]}||||dS||||jdS)r check_withr#ziThe 'validator' rule was renamed to 'check_with'. Please update your schema and method names accordingly.N) r\r rrrDeprecationWarningr_validate_check_withr|)rchecksrr value_checkerr1s r rz"BareValidator._validate_check_withrs fi ( ( .  $ 7 7 f M M     $ 7 7 V L L @&  M% ' ' ' ' '  ) ) . ; ;))!UE:::: ; ; F5% - - - - -s.5A&%A&c6t|tsdSt|trt|trt|f}nt|}|t|z }|r#||t j|dSdS)z{'empty': False }N)r\rr r>r|r MISSING_MEMBERS)rexpected_valuesrrmissing_valuess r _validate_containsz BareValidator._validate_containss%**  F/844 3 Y9 9  3"?"455OO!/22O(3u::5  G KKv5~ F F F F F G Gr"cjt|tst|ttfs|f}t|tr|||n+t|tr||||j|j |dfz dSdS)zD{'type': ('dict', 'hashable', 'list'), 'check_with': 'dependencies'} dependenciesNT) r\r rrr._BareValidator__validate_dependencies_sequence-_BareValidator__validate_dependencies_mappingrIfetch_node_fromrM)rrrrs r _validate_dependenciesz$BareValidator._validate_dependenciess lI . . +j 8W-7 7  +)?L lH - - F  1 1, F F F F  g . . F  0 0u E E E  $ 4 4 E>#::    4   r"czd}i}|D]k\}}t|trt|tr|g}||\}}||vr|dz }T|||il|t |kr#||tj |dSdS)Nrrt) r r\rr rrNrgr|r DEPENDENCIES_FIELD_VALUE) rrrvalidated_dependencies_counter error_infodependency_namedependency_values wanted_fieldwanted_field_values r __validate_dependencies_mappingz-BareValidator.__validate_dependencies_mappings)*& 2>2D2D2F2F I I .O./:: 8j!9?? 8&7$7!/3/A/A//R/R ,L,!%666.!3..!!?4F"GHHHH )S->-> > > KKv> K K K K K ? >r"c|D]>}||d!||tj|?dS)Nr)rr|r DEPENDENCIES_FIELD)rrr dependencys r __validate_dependencies_sequencez.BareValidator.__validate_dependencies_sequencesR& J JJ!!*--a08 E6#{'type': ('hashable', 'list'), 'schema': {'type': 'hashable'}}rvc3*K|] }|jvVdSr)rD)rexcluded_fieldrs r rz3BareValidator._validate_excludes..s*UU>~.UUUUUUr"z, c3@K|]}d|VdS)z'{0}'N)r)rrs r rz3BareValidator._validate_excludes..s?&&*/u%%&&&&&&r"N) r\r rArRrCrirzanyr"r|r EXCLUDES_FIELD)rexcluded_fieldsrrr exclusion_strs` r _validate_excludesz BareValidator._validate_excludess6 ox 0 0 0./O ;u  ! !*d.> ? ? 4  ( , ,U 3 3 3- A AN,,U1C1G1GD,22,,00@@@ UUUU_UUU U U E II&&3B&&&M KKv4m D D D D D  E Er"cNt|trht|tsSt|t|z}|r0||t jt|dSdS||vr#||t j|dSdS)z{'type': 'list'}N) r\rr r>r|r FORBIDDEN_VALUESr<FORBIDDEN_VALUE)rforbidden_valuesrrrs r _validate_forbiddenz!BareValidator._validate_forbiddens eX & & Bz%/K/K BE S)9%:%::I M E6#:DOOLLLLL M M((( E6#95AAAAA)(r"ct|t|kr>||tjt|t|dSt dt |D}|||df|}|t dt |D|jds(||tj|j dSdS)z'{'type': 'list', 'check_with': 'items'}c3$K|] \}}||fV dSrr-)rrk definitions r rz0BareValidator._validate_items..s;$1AzJr"r rc3$K|] \}}||fV dSrr-)rrkrs r rz0BareValidator._validate_items..s*BBHAuaZBBBBBBr"FrNrmN) rgr|r ITEMS_LENGTHr9rfrrN BAD_ITEMSrF)rr rr3rAr#s r _validate_itemszBareValidator._validate_itemss u::V $ $ KKv2CJJF L L L L L5>u5E5EF11$#W-2I 9BB &0A0ABBBBB{ H  E6#3Y5FGGGGG  H Hr"cd}tj}t|D]\}}||i} dD]7} | | |vr+| |j|vr|j|| | || <8d| |vr|j| |d<||||f| d} | |j|jdr|dz }| | j gd g| | j ||fS) zl Validates value against all definitions and logs errors according to the operator. r)rBr4rBT)rrArBFrrt) r rErfrrArBrrDrNrrFrx) roperatorrnrr valid_counterrFrkrrArr#s r __validate_logicalz BareValidator.__validate_logical sF  "$$&{33 2 2MAzZ__../F1 C Cve},,U9K1K1K*.+e*N>N O O O O O :r"c |d|||\}}|t|kr2||tj||t|dSdS)z${'type': 'list', 'logical': 'allof'}allofN)rrgr|r ALLOFrs r _validate_allofzBareValidator._validate_allof-sd11';uUU C $$ $ $ KKv|Wfc+>N>N O O O O O % $r"c |d|||\}}|dkr2||tj||t |dSdS)z%{'type': 'list', 'logical': 'noneof'}noneofrN)rr|r NONEOFrgrs r _validate_noneofzBareValidator._validate_noneof3sZ11(KPUVV A:: KKv}gvs;?O?O P P P P P :r"c |d|||\}}|dkr2||tj||t |dSdS)z${'type': 'list', 'logical': 'oneof'}oneofrtN)rr|r ONEOFrgrs r _validate_oneofzBareValidator._validate_oneof9sY11';uUU Q;; KKv|Wfc+>N>N O O O O O ;r"cz ||kr"||tjdSdS#t$rYdSwxYwz{'nullable': False }N)r|r MAX_VALUErh)r max_valuerrs r _validate_maxzBareValidator._validate_max?Y y   E6#344444!     DD  &, ::cz ||kr"||tjdSdS#t$rYdSwxYwr)r|r MIN_VALUErh)r min_valuerrs r _validate_minzBareValidator._validate_minGrrct|trCt||kr2||tjt|dSdSdSz{'type': 'integer'}N)r\rrgr|r MAX_LENGTH)r max_lengthrrs r _validate_maxlengthz!BareValidator._validate_maxlengthOY eX & & >3u:: +B+B KKv0#e** = = = = = > >+B+Br"ct|trCt||kr2||tjt|dSdSdSr)r\rrgr|r MIN_LENGTH)r min_lengthrrs r _validate_minlengthz!BareValidator._validate_minlengthVrr"c|I|s ||tj|dddddddd d d d d ddddddSdS)rBNrrrr5rr r minmaxrrrrrrAr4r )r|r NOT_NULLABLEr)rr2rrs r _validate_nullablez BareValidator._validate_nullable[s = 8 E6#6777  & &#      =r"c t|tr|||dftfd|D}|td|DdsH||jgddg||tj |jd Sd Sd S) {'type': ['dict', 'string'], 'check_with': 'bulk_schema', 'forbidden': ['rename', 'rename_handler']} r c3 K|]}|fV dSrr-rrrAs r rz4BareValidator._validate_keysrules..~s'??Qa[??????r"rc3K|]}||fV dSrr-rs r rz4BareValidator._validate_keysrules..s&"@"@aAq6"@"@"@"@"@"@r"FrtrurN) r\rrr9keysrrFr|r KEYSRULES)rrArrr#s ` r _validate_keysrulesz!BareValidator._validate_keysrulests eW % % H11$#[1????%**,,???@@2I 9T"@"@5::<<"@"@"@AAUSSS H001BBAOOO E6#3Y5FGGGGG H H  H Hr"c|ru|js ||tjtj|j|j|fzv}|jr|r|dSdSdSdS)rBN)rr|r READONLY_FIELDrIrrLr)rr3rr has_errors r rPz BareValidator._validate_readonlys  -& : E6#8999 %+==&%1  " -y -**,,,,, - - - - - -r"ct|tsdS|ds|dz }tj|}||s"||tjdSdS)z{'type': 'string'}N$) r\r endswithrecompilematchr|r REGEX_MISMATCH)rpatternrrre_objs r _validate_regexzBareValidator._validate_regexs%++  F$$  sNGG$$||E"" 6 KKv4 5 5 5 5 5 6 6r"z {'type': 'boolean'} cD tfdjD}n.#t$r!jrjddkrt wxYw|jz}|tfdDz }|D]"}|tj #jrbtfdD}j |r/j|z D]&}|tj #dSdSdS)zy Validates that required fields are not missing. :param document: The document being validated. c3K|]9\}}|djdu5|V:dS)rvTN)rrRrC)rrrrs r rz;BareValidator.__validate_required_fields..sl%E:**:66:::tGWXXr"rrAc3TK|]"}|j|V#dSr)rRrc)rrrDrs r rz;BareValidator.__validate_required_fields..sI! ! ||E"".d6M. ....! ! r"c3FK|]}||VdSrr;)rrrDs r rz;BareValidator.__validate_required_fields..s4XX5 U8K8K8W8W8W8W8WXXr"N) r>rAr AttributeErrorrrMr/rir|r REQUIRED_FIELD isdisjoint)rrDrvmissingrfieldss`` r __validate_required_fieldsz(BareValidator.__validate_required_fieldss )-):):)<)<HH    } !1"!5!A!A**   D00S! ! ! ! ! !! ! !      6 6E KKv4 5 5 5 5  ' >XXXXHXXXXXF+66v>> >!9FB>>EKKv'<====  > > > >>>s 27+A"c|dSt|tr.t|ts||||dSt|tr||||dSdS)z {'type': ['dict', 'string'], 'anyof': [{'check_with': 'schema'}, {'check_with': 'bulk_schema'}]} N)r\rr (_BareValidator__validate_schema_sequencer'_BareValidator__validate_schema_mapping)rrArrs r _validate_schemazBareValidator._validate_schemas > F eX & & Az%/K/K A  + +E65 A A A A A w ' ' A  * *5&% @ @ @ @ @ A Ar"c ||}||j|}|||df||d|j|d|j} |||jds(||tj |j dSdS#t$r"||tj wxYw)NrArBrC)rrrArBrCFr)rrrArrRrBrCrNr|r MAPPING_SCHEMArFr/BAD_TYPE_FOR_SCHEMA)rrrAr field_rulesr#s r __validate_schema_mappingz'BareValidator.__validate_schema_mappings%%f----dk%.@AA -- *%///4;MNN# t7GHH .   9U4;%HHH M E6#8):KLLLLL M M#    KKv9 : : :  s 9C,C.ctfdtt|D|||df|j}|tdt |D|jd|jrE||jgdg| |tj |jdSdS)Nc3 K|]}|fV dSrr-)rrkrAs r rz;BareValidator.__validate_schema_sequence..s'>>q6{>>>>>>r"rA)rrrArBc3$K|] \}}||fV dSrr-)rrkr1s r rz;BareValidator.__validate_schema_sequence..s*66TQ1a&666666r"Frru) r9r2rgrrBrfrNrFrr|r SEQUENCE_SCHEMA)rrrArr#s ` r __validate_schema_sequencez(BareValidator.__validate_schema_sequences>>>>E#e**,=,=>>>??-- *, .   66Yu%5%5666 7 7;      J  , ,Y->QC H H H KKv5y7H I I I I I J Jr"c|sdSt|tr|fn|}|D]p}|j|}|,t||jot||j }n!|d|}||}|rdSq||tj | dS)zM {'type': ['string', 'list'], 'check_with': 'type'} N validate_type) r\r rrRincluded_typesexcluded_typesrr|r BAD_TYPEr) r data_typerrr_typetype_definitionmatched type_handlers r _validate_typezBareValidator._validate_types   F *9i @ @O i  E#044U;;O*$?9L$UO,JKKK $66NN &,u--   E6?+++ ""$$$$$r"c^|df}t|tr|||tfd|D}|||jd|jrG||jgdg||tj |jdSdSdS)rr c3 K|]}|fV dSrr-rs r rz6BareValidator._validate_valuesrules..%s'77AQK777777r"rFrruN) r\rrr9rNrFrr|r VALUESRULES)rrArrrr#s ` r _validate_valuesrulesz#BareValidator._validate_valuesruless }- eW % % J11$)7777777772I IeDK5 A A A A  J001BBLLL E6#5y7HIIIII J J J Jr"rrr)NFT)rr*r+r,r#rzrrbytes bytearrayrr r rrrr:r rr>rrorU staticmethodrOrQ classmethodrrr|rrrrrrpropertyrBrgrCr rcrrrdrerrrrrrArrrrrrrrrrr rrrrrrrrFrGrrrXrYro__call__rqrkrjr&_validate_allow_unknownrrrrrrrrrrrrrrrrrr_validate_metarrrrPr _validate_required_validate_require_allrlrrrr/r3 __classcell__rXs@r r1r1;s--^* E !.E9+=rBB!>)dWb99#^K) |LLvw33"N:{B??vz266%))j]B??v{YLAA .J+>HH~ecVR00 .I<<<  MSUUN 1.1.1.1.1.f 9 9\ 9###(##[#O-O-O-b----^YYY."""<88X8... 66X6,,,00X0==X=33333X399X9///88X8...99X9///JJXJFFXF@@X@JJXJ666<<X<X ]::]:DDXD333  B B B '''', ' ' '"!!!!0,B0PPP>&&&4 + + ++++$ + + ++++ \ \    &VVV)A)A)AV222 - - -(&(&(&(&TH ! ! ! 5 5 5%%%%%%T87 ; BBB...8GGG (LLL$JJJ = = =EEE,BBBHHH(&&&6PPP PPP QQQ PPP >>> /.r22N>>> 2HHH ---"666323NOO556QRR">">">H A A A"JJJ$ % % %DJJJJJJJr"r1z7The rule's arguments are validated against this schema:c2eZdZdZfdZfdZdZxZS)InspectedValidatorzMetaclass for all validatorscd|dvr.|dd|ddjitt|j|g|RS)Nr#rurtr)rNr#rTrA__new__)rqrVrXs r rCzInspectedValidator.__new__3s^ DG # # GNNItAwqz'9: ; ; ;5u'--5cADAAAAr"cfd}ttj|dic__|dD]^}|dr'xj|t ddfz c_>d|zj|<_jrtdttd|dDtd |d Dz_ jdd }j x|d d d d d<|dd<dj DD]}dj|d<ddic_ __|dD]}|dr'xj |t ddfz c_ >|dr'xj|t ddfz c_zd|zj|<dD]B}j|d }j x|d d d d d<|dd<Cjjdd d d<i_jjjjdS)NcVtfdtDS)Nc3K|]9}|dzdz|tdzdV:dS)rruN)rrg)rr prefixs r rzNInspectedValidator.__init__..attributes_with_prefix..:sg<<f s 233#f++/##$r")r]dir)rGrqs`r attributes_with_prefixz;InspectedValidator.__init__..attributes_with_prefix9sBS r"r-rotype_ _validate_z}Methods for type testing are deprecated, use TypeDefinition and the 'types_mapping'-property of a Validator-instance instead.c3K|]}|VdSrr-rs r rz.InspectedValidator.__init__..Vs"MM1QMMMMMMr"rc3K|]}|VdSrr-rs r rz.InspectedValidator.__init__..Vs;V V AV V V V V V r"r#rrtrArruc3&K|] }|dk|V dS)r2Nr-rs r rz.InspectedValidator.__init__..\s&MM1Q*__Q____MMr"Trvrmcoerce_default_setter_ _normalize_)rrErW)rTrArUrvalidation_rulesrrg$_InspectedValidator__get_rule_schemarrr]checkersrzcoercersdefault_settersrrrN)rqrVrI attributer rrXs` r rUzInspectedValidator.__init__8sl      0 #&&/668:B5!5// ;;  I##G,, ''Ic'llnn,E+GG'''252G2G 9,33$Y//  "  #    MM(>(>|(L(LMMMMMPUV V --k::V V V Q Q      .w 7BE,N!Xw"9-!YMM 9MMM : :D59C  &z 2 2EGRB c)3+B// <<  I##I..  3y>>+;+;!< >> %%&788 ## #6G2H2H2J2J(K'MM###585J5J!I-66' 221 S SD'-g6AFIl RAaDN7 #A &y 1AaDOO    01':1=    -... 011111r"c^t||j}|i}n^t|vr |td} t |}n#t $ri}YnwxYw|s2|dkr,td|dddz|S)Nrtr;z>No validation schema is defined for the arguments of rule '%s'rrur)rr#RULE_SCHEMA_SEPARATORrrstriprr)rq method_name docstringrs r __get_rule_schemaz$InspectedValidator.__get_rule_schemausC--5  FF$ 11%OO,ABB1E  %ioo&7&788     +)999 $**322267     s!A'' A65A6)r*r+r,r#rCrUrSr>r?s@r rArA0sl&&BBBBB ;2;2;2;2;2zr"rA Validator)* __future__rastrrrrrwarningsrcerberusr cerberus.platformr r r r rrrrcerberus.schemarrrrcerberus.utilsrrrToyErrorHandlerrr&rr(r/objectr1rYr4rAr^r-r"r rhsI&&&&&&########                      XWWWWWWWWW*F*,,         I        9   oJoJoJoJoJFoJoJoJd/RWWWWWWWWt  {],