Custom boolean values create a field_error when trying to validate
See original GitHub issueOverview
We have a data package that defines custom values to represent “true” or “false” on boolean fields, as defined in the specs. When trying to validate this, frictionless-py raises a field_error.
How to reproduce
- Create a file named
bool.csv
like this:
id,question
0,confirm
1,deny
2,deny
3,confirm
-
Create a Python environment and
pip install frictionless==4.1.2
. -
Code to test:
from frictionless import describe_resource, validate_schema, validate_resource
r = describe_resource('bool.csv')
f = r.schema.get_field('question')
f.type = 'boolean'
f.format = {
'trueValues' : ['confirm'],
'falseValues' : ['deny']
}
- Now the problem:
[6]: validate_schema(r.schema)
[6]: {'version': '4.2.1',
'time': 0.001,
'errors': [{'code': 'field-error',
'name': 'Field Error',
'tags': [],
'note': '"{\'name\': \'question\', \'type\': \'boolean\', \'format\': {\'trueValues\': [\'confirm\'], \'falseValues\': [\'deny\']}} is not valid under any of the given schemas" at "" in metadata and at "anyOf" in profile',
'message': 'Field is not valid: "{\'name\': \'question\', \'type\': \'boolean\', \'format\': {\'trueValues\': [\'confirm\'], \'falseValues\': [\'deny\']}} is not valid under any of the given schemas" at "" in metadata and at "anyOf" in profile',
'description': 'Provided field is not valid.'}],
'tasks': [],
'stats': {'errors': 1, 'tasks': 0},
'valid': False}
- Also:
[7]: validate_resource(r)
[7]: {'version': '4.2.1',
'time': 0.004,
'errors': [{'code': 'field-error',
'name': 'Field Error',
'tags': [],
'note': '"{\'name\': \'question\', \'type\': \'boolean\', \'format\': {\'trueValues\': [\'confirm\'], \'falseValues\': [\'deny\']}} is not valid under any of the given schemas" at "" in metadata and at "anyOf" in profile',
'message': 'Field is not valid: "{\'name\': \'question\', \'type\': \'boolean\', \'format\': {\'trueValues\': [\'confirm\'], \'falseValues\': [\'deny\']}} is not valid under any of the given schemas" at "" in metadata and at "anyOf" in profile',
'description': 'Provided field is not valid.'}],
'tasks': [],
'stats': {'errors': 1, 'tasks': 0},
'valid': False}
Please preserve this line to notify @roll (lead of this repository)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to set FieldError field in a custom jsr 303 validation
I am creating a webservice in spring. I have a Params DTO which is nested in my OtherParentDTO's. Each request may contain only...
Read more >FieldError (Spring Framework 6.0.3 API)
Encapsulates a field error, that is, a reason for rejecting a specific field value. See the DefaultMessageCodesResolver javadoc for details on how a...
Read more >Spring Validation Example - Spring MVC Form Validator
We can create our custom validator implementations in two ways - the first one is to create an annotation that confirms to the...
Read more >Example usage for org.springframework ... - Java2s.com
Create a new FieldError instance. Usage. From source file:com.company.simple.util.validator.GlobeValidator.java protected void processConstraintViolations( ...
Read more >zod/ERROR_HANDLING.md at master · colinhacks/zod - GitHub
This guide explains Zod's internal error handling system, and the various ways you can customize it for your purposes. ZodError. All validation errors...
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
Oh, I see.
Thanks for looking into it, @roll . 😄
Sorry for misunderstanding the specs. 😟
Hi @augusto-herrmann
I guess, the specs’ text is confusing. It’s not the
field.format
it’s thefield.[property]
: