set method
void
set(
- JsonPath path,
- dynamic value, {
- AttributeSource source = AttributeSource.model,
override
Sets a value in the underlying model
Implementation
@override
void set(JsonPath path, value,
{AttributeSource source = AttributeSource.model}) {
try {
if (source == AttributeSource.control) {
_isModified = true;
}
_set(path, value);
_changeStream.add(Attribute(path, value, source: source));
final validator = validators[path];
final validationResult = validator?.call(value);
if (validationResult != null) {
addError(
path,
ValidationError.ofString(
path,
validationResult,
debugMessage: "Custom validator",
),
source: source);
} else {
/// Changed this to [model] because typing updates in the form control
/// wasn't triggering errors to update
clearError(path, source: source);
}
} catch (e) {
log.warning("Invalid value in form for $path: $e");
/// In the case of an error
addError(
path,
ValidationError.ofString(path, "Invalid value.", debugMessage: "$e"),
source: source,
);
}
}