This is a migrated thread and some comments may be shown as answers.

Validation "min" is not working?

2 Answers 707 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Jairo
Top achievements
Rank 1
Jairo asked on 19 Jun 2017, 06:27 PM

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 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 21 Jun 2017, 11:03 AM
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.
0
Jairo
Top achievements
Rank 1
answered on 21 Jun 2017, 02:41 PM
Thanks Preslav.
Tags
Validation
Asked by
Jairo
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Jairo
Top achievements
Rank 1
Share this question
or