desmos-labs / mooncake

The first decentralized social app based on Desmos
MIT License
46 stars 14 forks source link

Fix/edit profile input 87 #94

Closed ryuash closed 4 years ago

ryuash commented 4 years ago

Description

closes #87

Checklist

codecov[bot] commented 4 years ago

Codecov Report

Merging #94 into master will decrease coverage by 0.00%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
- Coverage   17.79%   17.78%   -0.01%     
==========================================
  Files         258      258              
  Lines        6295     6298       +3     
==========================================
  Hits         1120     1120              
- Misses       5175     5178       +3     
Impacted Files Coverage Δ
...ount_edit_screen/blocs/edit/edit_account_bloc.dart 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0cca650...4b8a21a. Read the comment docs.

ryuash commented 4 years ago

The changes looks great 🚀

Is it possible however to also implement a validation inside the input field to make sure the user does not insert non-valid characters inside his DTag? That means checking that it respects the following RegEx:

^[A-Za-z0-9_]+$

And has a length from 3 to 30 characters (included)

@RiccardoM I'm pretty sure you already implemented this. I'm unable to click save if the dTag isn't valid

bool get isDTagValid {
    final originalDTag = originalAccount.dtag?.trim() ?? "";
    final newDTag = account.dtag?.trim() ?? "";

    if (originalDTag.isNotEmpty && newDTag.isEmpty) {
      return true;
    }

    return RegExp(r"^[A-Za-z0-9_]+$").hasMatch(newDTag) &&
        newDTag.length >= 3 &&
        newDTag.length <= 20;
  }
 /// Tells whether the user can save the profile or not.
  bool get canSave {
    return containsCustomData && isDTagValid && isMonikerValid;
  }
RiccardoM commented 4 years ago

@RiccardoM I'm pretty sure you already implemented this. I'm unable to click save if the dTag isn't valid

bool get isDTagValid {
    final originalDTag = originalAccount.dtag?.trim() ?? "";
    final newDTag = account.dtag?.trim() ?? "";

    if (originalDTag.isNotEmpty && newDTag.isEmpty) {
      return true;
    }

    return RegExp(r"^[A-Za-z0-9_]+$").hasMatch(newDTag) &&
        newDTag.length >= 3 &&
        newDTag.length <= 20;
  }
 /// Tells whether the user can save the profile or not.
  bool get canSave {
    return containsCustomData && isDTagValid && isMonikerValid;
  }

Ok then, perfect :joy:!