issue while using "unique: true" for the sequence data type
- Dominant language
- Python
- Stars
- 297
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
### Environment
* Python version: 3.5.2
* PyKwalify version: 1.8.0
### Steps to Reproduce
1. create input YML file as below
test.yml
---
mydata:
name: 123
age: ABCD
hobbies: [cooking, painting, cooking]
2. create YML schema as below
---
```
type: map
mapping:
mydata:
type: map
mapping:
name:
type: str
range:
min: 1
max: 10
age:
type: int
range:
min: 21
max: 100
hobbies:
type: seq
sequence:
- type: str
unique: true
required: true
```
3. Write Python test case for validation as below
validate_yml.py
```
#! /usr/bin/python3
@author: Minal Deshmukh
import pykwalify
from pykwalify.core import Core, SchemaError
from pykwalify.errors import RuleError
yaml_file = "./test.yml"
schema_file = "./schema.yml"
yaml_schema = Core(source_file=yaml_file, schema_files=[schema_file])
try:
pykwalify.init_logging(0)
yaml_schema.validate(raise_exception=True)
except (SchemaError, RuleError):
for error in yaml_schema.errors:
print("error -->",error)
print ("Data Type of error is -->",type(error))
```
4. Execute test case as below
python3 validate_yml.py
OUTPUT
```
error --> Value 'ABCD' is not of type 'int'. Path: '/mydata/age'
Data Type of error is -->
error --> Value '123' is not of type 'str'. Path: '/mydata/name'
Data Type of error is -->
error --> Value 'cooking' is not unique. Previous path: '/mydata/hobbies/0'. Path: '/mydata/hobbies/2'
Data Type of error is -->
```
### Schema
```
type: map
mapping:
mydata:
type: map
mapping:
name:
type: str
range:
min: 1
max: 10
age:
type: int
range:
min: 21
max: 100
hobbies:
type: seq
sequence:
- type: str
unique: true
required: true
```
### Data
```
mydata:
name: 123
age: ABCD
hobbies: [cooking, painting, cooking]
```
### Expected Behavior
Expected data type of the error below is 'pykwalify.errors.SchemaError.SchemaErrorEntry'
error --> Value 'cooking' is not unique. Previous path: '/mydata/hobbies/0'. Path: '/mydata/hobbies/2'
Data Type of error is -->
### Observed Behavior
Data type is different than the other error data types
error --> Value 'cooking' is not unique. Previous path: '/mydata/hobbies/0'. Path: '/mydata/hobbies/2'
Data Type of error is -->
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.