Default

This method will set a default value that will be used when you pass null or undefined or even when you don't pass any value to the validate method

import Schema from "@rapidom/schema";

const Validator = Schema.number().default(0);

// All these cases will return 0
Validator.validate();
Validator.validate(null);
Validator.validate(undefined);
circle-info

Once the default value is set, there's no use to make the validator required anymore

circle-exclamation

Last updated