validate method

Future<bool> validate({
  1. dynamic value,
})

Validates that value does not already exist for the configured column.

Returns true when no existing model is found and the value is unique.

Example:

final isUnique = await UniqueRule<User>(column: 'email')
    .validate(value: 'jane@example.com');

Implementation

Future<bool> validate({dynamic value}) async {
  final model = await Model.firstWhere<T>(field: column, value: value);
  return model == null;
}