ajv#FormatDefinition TypeScript Examples
The following examples show how to use
ajv#FormatDefinition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.spec.ts From ajv-formats with MIT License | 6 votes |
describe("method get", () => {
test("should return format definition", () => {
const timeFormat = addFormats.get("time")
expect((timeFormat as FormatDefinition<string>).validate).toBeInstanceOf(Object)
const fastTimeFormat = addFormats.get("time", "fast")
expect((fastTimeFormat as FormatDefinition<string>).validate).toBeInstanceOf(RegExp)
expect(() => addFormats.get("unknown" as FormatName)).toThrow()
})
})
Example #2
Source File: formats.ts From ajv-formats with MIT License | 5 votes |
function fmtDef(
validate: RegExp | FormatValidator<string>,
compare: FormatCompare<string>
): FormatDefinition<string> {
return {validate, compare}
}