Code Monkey home page Code Monkey logo

Comments (3)

bovorasr avatar bovorasr commented on September 23, 2024 1

Mind if I knock some of these issues out for Hacktoberfest?

What do you think this should do for null values? Just jumping into this project, it looks like perhaps it should still throw a validation error when the string is null (?).

I'm basing that on the implementation of IsEqualTo, which states that null != null (two null values in IsEqualTo throws a validation error).

I can also see the argument for treating null like the empty string, but If MaxLength should treat a null value as effectively having a zero length, I'd be inclined to think that IsEqualTo should also treat null as being equal to null.

from valit.

bovorasr avatar bovorasr commented on September 23, 2024

The more I look at this, the more I think Required on string should not use IsNullOrEmpty, but instead should only check null. That's consistent with the implementation of of the value type extensions + an empty string is a valid string of zero length.

The implementation of the rest of the string extensions should then also only use a null check.

To illustrate why: as it is right now, A MinLength(0) rule cannot be satisfied, and this seems like a perfectly valid validation statement. Additionally, the value type extensions seem to define Required as meaning null only (in the nullable versions).

from valit.

GooRiOn avatar GooRiOn commented on September 23, 2024

Sorry for beeing so late to the party guys. From now on I'm gonna be more involved in Valit again.

I must say that I agree pretty much with all your statements. Using string.IsNullOrEmpty was wrong choice here. However I'm not quite sure what to do with this issue because changing these all string conditions to null-checks would mean quite serious change :/

@bovorasr I;ll look at your PR and decide what to do. Anyway thank you for beeing involved in this project :)

from valit.

Related Issues (20)

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.