Skip to content

Commit

Permalink
Tests for instancePath on propertyNames errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasfj committed Oct 30, 2024
1 parent 31a345c commit d6b49b2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/unit/json_schema/validation_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,27 @@ void main() {
expect(errors[0].message, contains('type'));
});

test('Object propertyNames', () {
final schema = createObjectSchema({
'propertyNames': {
'maxLength': 7,
}
});
final errors = schema.validate({
'someKey': {
'foo': true,
'foobar': true,
// property name "foobarbar" is longer maxLength of 7
'foobarbar': true,
}
}).errors;

expect(errors.length, 1);
expect(errors[0].instancePath, '/someKey/foobarbar');
expect(errors[0].schemaPath, '/properties/someKey/propertyNames');
expect(errors[0].message, contains('maxLength'));
});

test('Object additional properties not allowed', () {
final schema = createObjectSchema({
'properties': {
Expand Down

0 comments on commit d6b49b2

Please sign in to comment.