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

Typescript kendo.data.DataSourceSchemaModelFieldValidation required option is boolean

3 Answers 128 Views
Validation
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 15 Jan 2018, 09:42 AM

kendo.d.ts v2017.3.1026

should be 

 interface DataSourceSchemaModelFieldValidation {
   required?: boolean | { message: string };

}

 

to support custom required message.

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 17 Jan 2018, 08:45 AM
Hello John,

In order to set a custom messages you can use the approach illustrated in the example below:


For more information on defining and using custom messages please refer to this article.


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
John
Top achievements
Rank 1
answered on 17 Jan 2018, 09:08 AM

i use the approach of creating model definitions and use them many times in datasources.

     export var TALERTS_Model = kendo.data.Model.define({
        id: 'ALERT_ID',
        fields: {
            'ALERT_ID': { type: 'number' },
            'CLASS_NAME': { type: 'string', validation: { maxLength: 50, required: { message: 'this is required' } } },
            'DESCRIPTION': { type: 'string', validation: { maxLength: 100 } },
            'CATEGORY': { type: 'string', validation: { maxLength: 100 } },
        }
    });

 

the above is invalid because required accepts boolean only and not object.

kendo.d.ts

interface DataSourceSchemaModelFieldValidation {
    required?: boolean;
    min?: any;
    max?: any;
    minLength?: any;
    maxLength?: any;
    [rule: string]: any;
}

 

and is not the best solution to work with any data type when using typescript as when defining a model in datasource.

0
Accepted
Viktor Tachev
Telerik team
answered on 19 Jan 2018, 08:23 AM
Hi John,

Thank you for reporting the behavior to us. I have logged this and we will update the TypeScript definitions as soon as possible. Until then I can suggest modifying the Kendo typescript file locally so that there is no error when using custom messages. 

As a token of gratitude for reporting this to us I have updated your Telerik points. 


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Validation
Asked by
John
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
John
Top achievements
Rank 1
Share this question
or