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

Optional fields are not correctly validated #91

Open
matteocng opened this issue Jan 17, 2016 · 0 comments
Open

Optional fields are not correctly validated #91

matteocng opened this issue Jan 17, 2016 · 0 comments

Comments

@matteocng
Copy link
Contributor

If you ran the app below, inserted 'a' in all six email, link and quantity fields and saved, the red error label 'Required' would appear exclusively below the required() fields. Then, if you correctly filled in just the three required() fields, the save action would complete by saving 'null' in the DB for the three optional fields. It would be nice to abort the save action and show an error label below 'invalid' optional fields too.

We could also show 'Invalid data' instead of 'Required' to distinguish between 'empty required() field' and 'any field with validation error'.

A.app({
  appName: "Validation behaviour",
  appIcon: "heart",
  menuItems: [
    {
      name: "Gifts",
      icon: "gift",
      entityTypeId: "Gift",
    }
  ],
  entities: function(Fields) {
    return {
      Gift: {
        title: 'Gifts',
        fields: {
          item: Fields.text("Item").required(),
          quantity: Fields.integer("Quantity"),
          quantity_required: Fields.integer("Quantity Required").required(),
          email: Fields.email("Email"),
          email_required: Fields.email("Email Required").required(),
          link: Fields.email("Link"),
          link_required: Fields.email("Link Required").required()
        }
      }
    }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants