Object schema
A function which creates a parsing rule to ensure that a given value is an object.
Arguments
- A record of schemas
- (Optional): A custom object with error messages to be displayed when validation fails or there are type errors.
Example
import { object, string } from '@nordic-ui/validathor';
const objectRule = object({ name: string() }, 'Value must be an object');
try {
const parsedValue = objectRule.parse({ name: 'John Doe' });
console.log('Parsed value:', parsedValue);
} catch (error) {
console.error('Parsing failed:', error.message);
}