withOptionalProperty method
Adds a validation schema for an optional object property.
name
a property name.type
(optional) a property schema or type.rules
(optional) a list of property validation rules.
Implementation
ObjectSchema withOptionalProperty(String name,
[dynamic type, List<IValidationRule>? rules]) {
var schema = PropertySchema(name, type);
if (rules != null) {
schema.setRules(List.from(rules));
}
schema.makeOptional();
return withProperty(schema);
}