Skip to content

fge/json-schema-formats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Read me first

The license of this project is LGPLv3 or later. See file src/main/resources/LICENSE for the full text.

Note: this project is for the 2.0.x version of json-schema-validator; starting with 2.1.x, the format attributes defined in this package are integrated into json-schema-validator itself.

What it is

This is a project implementing format attributes not included in the JSON Schema drafts, which can be used to extend the validation capabilities of json-schema-validator.

Versions

The current version is 2.0.0.

Maven artifact

Replace your-version-here with the appropriate version:

<dependency>
    <groupId>com.github.fge</groupId>
    <artifactId>json-schema-formats</artifactId>
    <version>your-version-here</version>
</dependency>

Sample usage

This package comes with a dictionary of all defined format attributes. In order to use it, you need to create your own keyword library and add the format attributes you want to it. For instance, here is how you add the sha1 format attribute:

final Dictionary<FormatAttribute> dict = ExtraFormatsDictionary.get();
                
final LibraryBuilder lib = DraftV4Library.get().thaw();
lib.addFormatAttribute("json-pointer", dict.entries().get("json-pointer"));
                                        
final ValidationConfigurationBuilder cfg = ValidationConfiguration.newBuilder();
cfg.addLibrary("foo://bar", lib.freeze());

final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder()
    .setValidationConfiguration(cfg.freeze()).freeze();

// Now use the factory

List of format attributes

This is the list of format attributes supported by this package.:

  • base64,
  • md5,
  • sha1 (yes, git commit IDs use that),
  • sha256,
  • sha512,
  • mac,
  • json-pointer,
  • uri-template.

See the wiki for more information.

About

Format specifiers to use with json-schema-validator

Resources

Stars

Watchers

Forks

Packages

No packages published