EmailAddress.js 1.08 KB
/* global console */
define(
    [
        'underscore',
        'ofbiz/model/Base',
        'ofbiz/model/ContactMech',
    ],
    function(
        _,
        Base,
        ContactMech
    ) {
        'use strict';
        console.log('ofbiz/model/EmailAddress: loaded');
        return ContactMech.extend({
            defaults: {
                emailAddress: null,
            },
            validation: {
                emailAddress: [
                    {
                        pattern: 'email',
                        required: Base.createRequiredChecker('ofbiz/model/EmailAddress.emailAddress'),
                        maxLength: 255
                    },
                ]
            },
            parse: function(data) {
                if (data.infoString !== undefined) {
                    data = _.clone(data);
                    if (data.emailAddress === undefined) {
                        data.emailAddress = data.infoString;
                    }
                    delete data.infoString;
                }
                return data;
            },
        });
    }
);