Giter Site home page Giter Site logo

Improvements to validation logic about alpaca HOT 6 OPEN

gitana avatar gitana commented on July 16, 2024
Improvements to validation logic

from alpaca.

Comments (6)

uzquiano avatar uzquiano commented on July 16, 2024

There have been a number of validation logic updates over the past few days. Here is where we stand today:

#1 - To see the validation logic right away, the form should be loaded with an "edit" view. This is what gets loaded by default. So, by default, users should expect to see validation logic appear right away. (i.e. lots of red boxes on first render)

#2 - To hide the validation logic on first pass, the form should be loaded with a "create" view. You can do this by providing { "view": "VIEW_WEB_CREATE" } or creating your own view. Alternatively, you can hideInitValidationError on any of your fields individually.

#3 - If a field is in a valid state when clicked into, the field will remain in a valid state until the user clicks away (or blurs the field). Upon blur, the field's validation is recomputed and, if invalid, it will highlight with the red box. If the field was originally in an invalid state when clicked into, the field will revalidate on every keyUp() so that if the user enters a valid value, the validation state will clear up right away (i.e. red boxes go away).

#4 - When specifying a form, along with submit buttons, the submit button will be marked disabled until all of the properties of the form are valid. Furthermore, upon clicking the submit button, a recalculation of the form's validity is performed ahead of submitting the post.

Feedback and insights are appreciated. I think we're getting closer to having this right.

from alpaca.

Ognian avatar Ognian commented on July 16, 2024

Hello,
my use case is:

  1. I create the form with no data, since i'm using VIEW_WEB_EDIT_INLINE I have to set "hideInitValidationError": true on "all" fields
  2. Im "filling" the form with setDefault(); setValue(x); the data is correctly filled in, but NOT correctly validated, since validation is not triggered.

Step 2. is repeated multiple times...

.isValid(true) just returns the validation state of the form it thinks the form has .. .validate() does not validate again...
which is the main problem I have with validation now... (tried .renderValidationState() too without success)

What I want to say is that this is still confusing.
Of course there are 2 use cases:

  1. Where Data is available at the time of creation, this is how it works now
  2. Data is filled in later, this is what is handled by the HideInitValidationError flag on a per Field base

I think that this flag should be on a Form level and not on a field level
I think that this flag has nothing to do with the kind of view used to render the fields.

I think that one view for all fields could also be handled better, but this is a different issue (see #28 )

from alpaca.

StephenOwens-dcat avatar StephenOwens-dcat commented on July 16, 2024

I believe that in the case of wizards valdation should only occur for the currently visible fields. URI validation seems to break wizards where the URI fields are on anything other than the first step.

from alpaca.

ripfire44 avatar ripfire44 commented on July 16, 2024

The second item doesn't work when I have a submit button on the form. It shows validation message for all after I fill in the first field.
http://jsfiddle.net/35aKD/
If you remove the button property, it works as intended.

from alpaca.

piyushvyas901 avatar piyushvyas901 commented on July 16, 2024

how to put validation on height and width of the image while uploading using alpaca. Can someone please provide me small snippet for it

from alpaca.

mscheper avatar mscheper commented on July 16, 2024

re point 2 in @uzquiano's comment from 9 Feb 2013: { "view": "VIEW_WEB_CREATE" } causes this error: The desired view: VIEW_WEB_CREATE could not be loaded. Please make sure it is loaded and not misspelled.

I tried { view: 'web-create' } and { ui: 'web', type: 'create' }, and while neither resulted in an error, neither prevented the error messages from displaying, either. Is there a new way for preventing validation messages from appearing when the form is first rendered?

The Validation API topic says:

An example of this is when the hideInitValidationError flag is set true in the options for the form.

So I tried $myForm.alpaca({ schema: schema, ui: 'web', type: 'create', options: { form: { hideInitValidationError: true } }}), but that still didn't work. Help?

from alpaca.

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.