diff --git a/src/samplers/string.js b/src/samplers/string.js index ef30dba..e6f7182 100644 --- a/src/samplers/string.js +++ b/src/samplers/string.js @@ -104,6 +104,10 @@ function regexSample() { return '/regex/'; } +function binarySample() { + return [116, 101, 115, 116]; +} + const stringFormats = { 'email': emailSample, 'idn-email': idnEmailSample, // https://tools.ietf.org/html/rfc6531#section-3.3 @@ -125,6 +129,7 @@ const stringFormats = { 'json-pointer': jsonPointerSample, 'relative-json-pointer': relativeJsonPointerSample, // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01 'regex': regexSample, + 'binary': binarySample, }; export function sampleString(schema, options, spec, context) { diff --git a/test/unit/string.spec.js b/test/unit/string.spec.js index 46686b3..96b7471 100644 --- a/test/unit/string.spec.js +++ b/test/unit/string.spec.js @@ -135,6 +135,11 @@ describe('sampleString', () => { }); }); + it('should return binary for format binary', () => { + res = sampleString({format: 'binary'}); + expect(res).toEqual([116, 101, 115, 116]); + }); + it.each([ 'email', // 'idn-email', // unsupported by ajv-formats