Validate schema list error: RuntimeError: There's no handler for 'status' in the 'validate' domain.
See original GitHub issueUsing Stable Version I am trying cerberus for our validator and i have one testing python file as below:
from cerberus import Validator
from datetime import datetime, date, time
def string_toDatetime(string):
return datetime.strptime(string, '%Y-%m-%d')
schema={
'adminStatus':{
'type':'list',
'schema':{
'effectiveDates':{
'type':'dict',
'schema':{
'effectiveFrom':{'type':'datetime'},
'effectiveTo':{'type':'datetime'}
}
},
'status':{'type':'string','allowed':['Active','Inactive']},
'reason':{'type':'string'}
}
}
}
document={
'adminStatus':[
{
'effectiveDates':{
'effectiveFrom':string_toDatetime('2018-05-10'),
'effectiveTo':string_toDatetime('2018-05-11')
},
'status':'ctive',
'reason':'Expired'
},
{
'effectiveDates' : {
'effectiveFrom' :string_toDatetime('2018-05-11')
},
'status' : 'Inactive',
'reason' : 'Matured'
}
]
}
v=Validator(schema)
v.validate(document)
print(v.errors)
However I encounter some error like below:
File "E:\cerberus\cerberus_test.py", line 46, in <module>
v.validate(document)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 877, in validate
self.__validate_definitions(definitions, field)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 940, in __validate_definitions
result = validate_rule(rule)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 922, in validate_rule
return validator(definitions.get(rule, None), field, value)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 1234, in _validate_schema
self.__validate_schema_sequence(field, schema, value)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 1259, in __validate_schema_sequence
update=self.update, normalize=False)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 877, in validate
self.__validate_definitions(definitions, field)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 940, in __validate_definitions
result = validate_rule(rule)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 921, in validate_rule
validator = self.__get_rule_handler('validate', rule)
File "C:\Python27\lib\site-packages\cerberus\validator.py", line 338, in __get_rule_handler
"domain.".format(rule, domain))
RuntimeError: There's no handler for 'status' in the 'validate' domain.```
Am i using schema list correctly? Could anyone tell me why and how to correct it?
@funkyfuture
Many thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
There's no handler for [insert_filed_name] in the 'validate ...
I run the validation on both schemas and if neither of them passes, I raise an error. This sounds a bit hacky and...
Read more >Cerberus Documentation - Read the Docs
Cerberus schemas are built with vanilla Python types: dict, list, string, etc. Even user-defined validation rules are invoked in the schema ...
Read more >How to use the cerberus.Validator function in Cerberus - Snyk
resource_schema): print v.errors raise AssertionError("Output does not validate according to schema") if not v.validate(response.
Read more >Handling Validation Errors - python-jsonschema
The full schema that this error came from. This is potentially a subschema from within the schema that was passed in originally, or...
Read more >Full Stack Error Handling with GraphQL and Apollo
There are 3 phases to a GraphQL query and client-caused errors may ... of the validation error messages is not captured by your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So your schema definition is pretty close, you are just missing a ‘schema’ rule layer. If you check out the docs here, you will see their example for list item validation.
I believe the schema you were trying to create was as follows:
The first schema rule (with list) is used to define a schema for what each element in the list should look like. Then you need to specify a type (dict) and schema for those dictionaries that are expected as list elements.
Many Thanks ,
It was my small mistake because of which validation was not happening.
Now it is happening properly.
Thanks
Riju Bhasker
From: Connor Zapfel notifications@github.com Sent: 04 July 2019 10:57 To: pyeve/cerberus cerberus@noreply.github.com Cc: rijubhaskergslab riju.bhasker@gslab.com; Comment < comment@noreply.github.com> Subject: Re: [pyeve/cerberus] Validate schema list error: RuntimeError: There’s no handler for ‘status’ in the ‘validate’ domain. (#399)
Can you give me an example of data that fails to validate?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pyeve/cerberus/issues/399?email_source=notifications&email_token=AMEL3ZLGNTA2SI735DPBZMTP5WCZ3A5CNFSM4FCEDPDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZGLHAQ#issuecomment-508343170, or mute the thread https://github.com/notifications/unsubscribe-auth/AMEL3ZPLT2O6SZD7VDLL3WTP5WCZ3ANCNFSM4FCEDPDA .
– Confidentiality Notice and Disclaimer: This email (including any attachments) contains information that may be confidential, privileged and/or copyrighted. If you are not the intended recipient, please notify the sender immediately and destroy this email. Any unauthorized use of the contents of this email in any manner whatsoever, is strictly prohibited. If improper activity is suspected, all available information may be used by the sender for possible disciplinary action, prosecution, civil claim or any remedy or lawful purpose. Email transmission cannot be guaranteed to be secure or error-free, as information could be intercepted, lost, arrive late, or contain viruses. The sender is not liable whatsoever for damage resulting from the opening of this message and/or the use of the information contained in this message and/or attachments. Expressions in this email cannot be treated as opined by the sender company management – they are solely expressed by the sender unless authorized.