Skip to content

cmkweber/jsoncommon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsoncommon

Useful primitives for class based Json Schema Validation package json.

Description

Common primitives are provided such as JsonDate, JsonEmail, and JsonUrl, that are not considered strict json. The interface uses common types such as Date but serializes to strict json as a number. Additionally, included are common enumerations representing international formats such as County codes and Currencies. For more details see json.

Usage

Instantiate or extend from one of the provided json primitives.

JsonCountry

Enumeration that resolves to an ISO 3166-1 alpha-2 country code.

new JsonCountry(
	lowercase:boolean, // Lowercase country
	value?:Country // Default value
);

JsonCurrency

Enumeration that resolves to an ISO 4217 currency.

new JsonCurrency(
	lowercase:boolean, // Lowercase currency
	value?:Currency // Default value
);

JsonDate

Date that serializes to the amount of elapsed time since the Unix epoch.

new JsonDate(
	milliseconds:boolean, // Milliseconds or seconds
	min?:Date, // Minimum date value
	max?:Date, // Maximum date value
	value?:Date // Default value
);

JsonEmail

Regular expression that validates against the majority of valid email inputs.

new JsonEmail(
	value?:string // Default value
);

JsonState

Enumeration that resolves to an ISO 3166-2:US subdivision code.

new JsonState(
	lowercase:boolean, // Lowercase state
	value?:Country // Default value
);

JsonTimestamp

Date that serializes to an ISO 8601 time string.

new JsonTimestamp(
	min?:Date, // Minimum date value
	max?:Date, // Maximum date value
	value?:Date // Default value
);

JsonUrl

Utilizes URL for validation of url inputs.

new JsonUrl(
	value?:URL // Default value
);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published