Installation
Install the package in your app with:
npm install json-rest-schemaIf you are working in this repo and want to run the documentation site locally:
npm install
npm run docs:devBuild the full static site, including the standalone React and Vue demo apps, with:
npm run docs:buildPreview that built site locally with:
npm run docs:previewUpgrading to 1.0.17
Version 1.0.17 intentionally replaces the old permissive temporal behavior. There are no compatibility aliases or legacy parsers:
date,time, anddateTimenow validate JSON strings and return the exact input string unchanged. They no longer return JavaScriptDateobjects or parse numbers, locale text, SQL datetime strings, or otherDate.parse()inputs.dateaccepts only a real calendar date written asYYYY-MM-DD.timeaccepts an offset-freeHH:MM[:SS[.fraction]]value.dateTimeaccepts a calendar-valid RFC 3339 datetime with seconds and a mandatoryZor±HH:MMoffset.timestamphas been removed. UseepochMillisecondsorepochSeconds; both accept an integer number or canonical base-10 integer string and return a number.temporalPrecisionlimits fractional-second digits fortimeanddateTime. Excess precision is rejected, never truncated.- Applied defaults now pass through the normal type and validator pipeline.
Use this prompt with an agent working on an existing application:
Upgrade this application to
json-rest-schema1.0.17 without adding compatibility or legacy parsing. Find every temporal schema field and trace its producers, consumers, HTTP representation, database mapping, defaults, fixtures, and tests. Replacetype: 'timestamp'withepochMillisecondsorepochSecondsonly after verifying the actual unit. Keepdatevalues as validYYYY-MM-DDstrings,timevalues as offset-freeHH:MM[:SS[.fraction]]strings, anddateTimevalues as RFC 3339 strings with seconds and an explicit timezone. Convert JavaScriptDateobjects explicitly at application boundaries; do not make the schema accept them. Fordatetime-localcontrols, apply the product's intended timezone before producing RFC 3339—do not appendZunless the entered value is defined as UTC. Remove code that expects validation to return aDateor normalize a temporal string. Make storage adapters translate between these wire strings and database-native values. Update defaults to the new forms. Add tests for impossible dates, timezone-required datetimes, fractional precision, JSON round trips, repeated validation, captured HTTP payloads, and the relevant database round trip. Run the full test, lint, typecheck, and build suites and report every changed temporal contract.
The published docs site is the best place to read the same manual as shorter chapters for:
- create / replace / patch semantics
- nested object and array contracts
- recursive runtime validation and transport export
- field introspection and path-scoped validation
- React Hook Form, Vue + Vuetify, and VeeValidate adapters
- demo app walkthroughs