validateBuilderSchema method

bool validateBuilderSchema({
  1. required String type,
  2. required dynamic value,
  3. bool validate = true,
})

Validates the builder against it's value. This will only perform a validation if a schema id is associated with builder.

Because the validation is relatively expensive, the validation will only happen in DEBUG builds. In either RELEASE or PROFILE builds, this is disabled and will always return true.

Implementation

bool validateBuilderSchema({
  required String type,
  required dynamic value,
  bool validate = true,
}) {
  var result = true;

  assert(() {
    if (disableValidation != true) {
      var container = _builders[type];
      if (container?.schemaId != null) {
        result = SchemaValidator().validate(
          schemaId: container!.schemaId,
          value: value,
          validate: validate,
        );
      }
    }
    return true;
  }());

  return result;
}