Concepts

External data adapter

Try the free JavaScript compiler

Validate a provider-specific record and project the domain representation.

Formal Syntax & Structure

javascript syntaxjavascript
adapt(raw) → domain record

Working Example

Example Snippetjavascript
(async () => {function adapt(x){if(typeof x.code!=="string"||!Number.isInteger(x.on_hand)||x.on_hand<0)throw new TypeError("record");return {id:x.code,qty:x.on_hand};}console.log(JSON.stringify(adapt({code:"A",on_hand:4,extra:9})));})()
JavaScript Reference