Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to translate String in ordinary class without return Scaffold? #21

Closed
rrifafauzikomara opened this issue Aug 15, 2019 · 2 comments
Closed

Comments

@rrifafauzikomara
Copy link

I have the class for validation like here:

class Validator {

  String validateEmail(String value) {
    Pattern pattern =
        r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
    RegExp regex = new RegExp(pattern);
    if (value.length == 0 ) {
      return "Email tidak boleh kosong";
    } else if (!regex.hasMatch(value)) {
      return 'Email tidak valid';
    }
    return null;
  }

  String validatePassword(String value) {
    String pattern = r'(^[a-zA-Z0-9]*$)';
    RegExp regExp = new RegExp(pattern);
    if (value.length == 0) {
      return "Password tidak boleh kosong";
    } else if(value.length < 8){
      return "Password tidak boleh kurang dari 8";
    } else if(value.length > 15) {
      return "Password tidak boleh lebih dari 15";
    } else if (!regExp.hasMatch(value)) {
      return "Password harus menggunakan alfanumerik";
    }
    return null;
  }
}

How to translate the value of return String?

@rrifafauzikomara
Copy link
Author

I already ask StackOverflow too

@fajarainul
Copy link

@rrifafauzikomara how you solve this issue??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants