Validation "min" is not working?

3 posts, 0 answers
  1. Jairo
    Jairo avatar
    6 posts
    Member since:
    Mar 2017

    Posted 19 Jun Link to this post

    Good afternoon,

    So I have created this little example here: http://dojo.telerik.com/Ivipo

    The important thing is that I added "min: 1" to the UnitPrice field definition (in the model). So If I test this I must input a value in UnitPrice greater than 0, at least 1 to be valid right? but it is not... it only requires the "ProductName" to have something and then it saves the information... why? am I doing something wrong? did I miss something here?

    Could you please tell me where can I find the documentation about the properties that I can define for the "validation" object ?? things like "min" or "required"...

     

    Thanks!

     

     

  2. Preslav
    Admin
    Preslav avatar
    234 posts

    Posted 21 Jun Link to this post

    Hi Jairo,

    The reason for this behavior is the fact that by adding a new row, a new data record is inserted in the dataSource. Thus, no validation is applied there. Once inserted, the editCell or editRow method is invoked. In this case, editCell is invoked due to the incell editable configuration of the Grid and only the first cell is opened.
    Further, to overcome this, I would suggest using one of the following approaches:
    • Enable inline editing mode:
      editable: "inline"
    • set defaultValue in the schema.model.fields. For example:

      schema: {
          model: {
              id: "ProductID",
              fields: {
                  ProductID: {
                      editable: false,
                      nullable: true
                  },
                  ProductName: {
                      validation: {
                          required: true
                      }
                  },
                  UnitPrice: {
                      type: "number",
                      defaultValue: 1,
                      validation: {
                          min: 1,
                          required: true
                      }
                  },
                  Discontinued: {
                      type: "boolean"
                  },
                  UnitsInStock: {
                      type: "number",
                      defaultValue: 1,
                      validation: {
                          min: 1,
                          required: true
                      }
                  }
              }
          }
      }

    Finally, more information about the validator is available in this section:
    I hope this helps.


    Regards,
    Preslav
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Jairo
    Jairo avatar
    6 posts
    Member since:
    Mar 2017

    Posted 21 Jun in reply to Preslav Link to this post

    Thanks Preslav.
Back to Top