const validator: ConformDeepValidator = {
name: (name, srcObj) => name,
age: (age, srcObj) => age,
member: (member, srcObj) => !!srcObj.name === 'Bob', // Reference the source object
owes: (owes, srcObj) => Promise.resolve(owes + 100), // Return promises or values
valid: (valid, srcObj) => throw new Error('Sorry'), // Marks the object invalid
some_constant: 10000 // Resulting object will always contain this value.
}
The property matching value from the object being validated.
The entire object being validated.
Promise, Error, or value
Generated using TypeDoc
This function will be called by conformDeep with the matching property value of the object being validated and the entire source object under test as its second arg.
conformDeep
ConformDeepValidator