Typescript kendo.data.DataSourceSchemaModelFieldValidation required option is boolean

4 posts, 1 answers
  1. John
    John avatar
    8 posts
    Member since:
    May 2014

    Posted 15 Jan 2018 Link to this post

    kendo.d.ts v2017.3.1026

    should be 

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

    }

     

    to support custom required message.

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2497 posts

    Posted 17 Jan 2018 Link to this post

    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.
  3. John
    John avatar
    8 posts
    Member since:
    May 2014

    Posted 17 Jan 2018 in reply to Viktor Tachev Link to this post

    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.

  4. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    2497 posts

    Posted 19 Jan 2018 Link to this post

    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.
Back to Top