withRequiredProperty method

ObjectSchema withRequiredProperty(
  1. String name, [
  2. dynamic type,
  3. List<IValidationRule>? rules
])
inherited

Adds a validation schema for a required object property.

  • name a property name.
  • type (optional) a property schema or type.
  • rules (optional) a list of property validation rules.

Implementation

ObjectSchema withRequiredProperty(String name,
    [dynamic type, List<IValidationRule>? rules]) {
  var schema = PropertySchema(name, type);
  if (rules != null) {
    schema.setRules(List.from(rules));
  }

  schema.makeRequired();

  return withProperty(schema);
}