GithubHelp home page GithubHelp logo

dart-league / validators Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karan/validator.dart

82.0 82.0 27.0 121 KB

:turtle: String validation and sanitization for Dart.

Home Page: https://pub.dartlang.org/packages/validators

License: MIT License

Dart 100.00%

validators's People

Contributors

lo-bertolino avatar lucassaldanha avatar luisvargastije avatar luisvt avatar pmundt avatar scienticious avatar yongjhih avatar zeusbaba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

validators's Issues

Drop dependency to vin_decoder

I would like to propose that this package should remove its dependency on vin_decoder.
My reasoning is:

  • it looks like it is only used for this simple function:
/// check if the string is a valid ISO 3779-compliant Vehicle identification
/// number (VIN)
bool isVIN(String str) {
  VIN vin = VIN(number: str);
  return vin.valid();
}

which could be easily pasted by the users who need it

  • validators is used by many other packages
  • vin_decoder has many dependencies, e.g. to http , basic_utils and random_string which are also used by many other packages
  • therefore, it is likely to run into dependency conflicts because of all these transitive dependencies
  • I think the VIN feature is only used by a tiny fraction of users, but many are currently having issues with dependencies due to the migration to null safety

This would be a breaking change, but IMO it would be worthwhile. validators would then be a package without any dependencies.

isCreditCard invalid on bin 230744

If I try to valid a master card credit card number starting with 230744 from C6 Bank (Brazil) the function isCreditCard return false.

isUrl not validating tld

Given the following website:

website = http://www.example

When I call isURL on it with the following options, I get true, when I expected to get false as this is not a valid URL. I understand the requireTld option defaults to true.

isURL(website, requireProtocol: true, allowUnderscore: true)

I am using version ^2.0.0+1

Feature Requests for validators

Feature Request for some more validators:

  • isCIDR: check if value is a valid CIDR notation
  • isLocale: check if value is a valid locale string
  • isTimezone: check if value is a valid timezone string

Rename isNull to isNullOrEmpty

Because it does not only check if str == null but also checks if str.length == 0
(you could also refactor and use a built-in str.isEmpty instead of direct length accessing)

isURL hostWhitelist and hostBlacklist logic is inverted

The behaviour of hostWhitelist and hostBlacklist seems to be inverted.

My understanding is that if I add www.example.com as a whitelisted host, the method isURL should only return true if the host of the url being tested matches at least one of the values in the whitelist.

e.g.

If I have hostWhitelist = ['www.example.com'], and I test the string www.example.com, I'd expect the method to return true. And if I test the string www.another.com, I'd expect the method to return false.

In a similar manner, if I have hostBlacklist = ['www.example.com'], and I test the string www.example.com, I'd expect the method to return false. And if I test the string www.another.com, I'd expect the method to return true.

However, the code seems to be inverted.

if (hostWhitelist.isNotEmpty && hostWhitelist.contains(host)) {
  return false;
}

if (hostBlacklist.isNotEmpty && !hostBlacklist.contains(host)) {
  return false;
}

From https://github.com/dart-league/validators/blob/master/lib/validators.dart#L183-L189

validators ^2.0.1 requires json_annotation >=2.0.0 <=3.0.1

Can't upgrade json_annotation/json_serializable package...

Because no versions of validators match >2.0.1 <3.0.0 and validators 2.0.1 depends on vin_decoder ^0.1.2, validators ^2.0.1 requires vin_decoder ^0.1.2.

And because no versions of vin_decoder match >0.1.2 <0.2.0, validators ^2.0.1 requires vin_decoder 0.1.2.

And because vin_decoder 0.1.2 depends on basic_utils ^2.5.4 which depends on json_annotation >=2.0.0 <=3.0.1, validators ^2.0.1 requires json_annotation >=2.0.0 <=3.0.1.

So, because nudged depends on both json_annotation ^3.1.0 and validators ^2.0.1, version solving failed.

Dart 2.0 problem

When I try to get packages, I get this error;
`The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.

Because ***** depends on validator any which requires SDK version <2.0.0, version solving failed.

pub get failed (1)`

plans for null safety support

Are there plans to add null safety support to this package? If so can you estimate when? Thanks very much for your work.

url with protocol option

Passes validation with require_protocol option set true.

if (!validator.isURL('www.example.com',{'require_protocol':true} )){
  return 'Enter a valid URL (e.g. http://example.com)';
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.