ajv-validator / ajv-validator/ajv
Fail to validate a time value.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 14.8k
- Forks
- 1k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**What version of Ajv are you using? Does the issue happen if you use the latest version?**
`ajv: 8.18.0` and `ajv-formats: 3.0.1`
**Ajv options object**
```javascript
{allErrors: true}
```
**JSON Schema**
```json
{
"type":"object",
"properties":{
"time":{"type":["string","null"],"oneOf":[{"type":"string","format":"time"},{"type":"null"}]}
},
"required":[],
"additionalProperties":false
}
```
**Sample data**
```json
{time: "01:00:00"}
```
**Your code**
```javascript
import Ajv from 'ajv';
import addErrors from 'ajv-errors';
import addFormats from 'ajv-formats';
const ajv = new Ajv({allErrors: true});
addFormats(ajv);
addErrors(ajv);
const validate = ajv.compile(schema);
validate(sampleData);
```
**Validation result, data AFTER validation, error messages**
```
[
{
instancePath: '/time',
schemaPath: '#/properties/time/oneOf/0/format',
keyword: 'format',
params: { format: 'time' },
message: 'must match format "time"'
},
{
instancePath: '/time',
schemaPath: '#/properties/time/oneOf/1/type',
keyword: 'type',
params: { type: 'null' },
message: 'must be null'
},
{
instancePath: '/time',
schemaPath: '#/properties/time/oneOf',
keyword: 'oneOf',
params: { passingSchemas: null },
message: 'must match exactly one schema in oneOf'
}
]
```
**What results did you expect?**
`validate` function should return `true`.
**Are you going to resolve the issue?**
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.