Giter VIP home page Giter VIP logo

foolproof's Introduction

foolproof

MVC Foolproof Validation aims to extend the Data Annotation validation provided in ASP.NET MVC.

foolproof's People

Contributors

agrath avatar gareth-evans-sniper avatar leniel avatar stevecookms 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

Watchers

 avatar  avatar  avatar  avatar

foolproof's Issues

NotEqualTo validation false

If i send the value as empty and not send the dependent value the validation failed, and using the NotEqualTo attribute,
I.e: email and alternative email

RequireIf RegEx is lost when dependant property is number

To reproduce : Declare Field1 is required when Field2 match the following regular expression
^[a-zA-Z0-9]{0,10}$

See the debug progress in latest Chromeversion :

image

As he detect "value1" as numeric, value2 will be NaN just few line below.

image

You should not apply all these override logics if "operator" is RexMatch/NotRegExMatch

Foolproof cannot perform client-side time validation

While the library can perform client-side date validation, validating fields marked with [DataType(DataType.Time)] and rendered as times (e.g., in the format "hh : mm") will not validate correctly.

To solve this issue, I performed the following changes to mvcfoolproof.core.js:

  • Added a "isTime" function right above the isDate local function:
    var isTime = function (input) {
        return moment(input, ['h:m a', 'H:m']).isValid();
    };
  • Changed the checks below that region from:
    if (isDate(value1)) {
        value1 = Date.parse(value1);
        value2 = Date.parse(value2);
    } else if (isBool(value1)) {
        if (value1 == "false") value1 = false;
        if (value2 == "false") value2 = false;
        value1 = !!value1;
        value2 = !!value2;
    }
    ...

to

    if (isTime(value1)) {
        value1 = moment(value1, ['h:m a', 'H:m']);
        value2 = moment(value2, ['h:m a', 'H:m']);
    }
    else if (isDate(value1)) {
        value1 = Date.parse(value1);
        value2 = Date.parse(value2);
    }
   ...

and now it works. The bad thing about the above is that I have introduced a dependency on moment.js, I don't know if was already used by the library before.

Hope this can help other people also trying to validate hour/minute intervals.

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.