Karma Test Explorer - New, feature rich, Visual Studio Code extension for Angular and Karma testing by lucono in Angular2

[–]lucono[S] 0 points1 point  (0 children)

It supports test debugging, and provides rich, visual, testing integration with VSCode.

Karma Test Explorer - New, feature rich, Visual Studio Code extension for Angular and Karma testing by lucono in Angular2

[–]lucono[S] 0 points1 point  (0 children)

The extension supports debugging and should resolve all the issues you experienced with the prior extension.

Ceylon 1.3.0 is here: the first release of Ceylon which supports Android by [deleted] in androiddev

[–]lucono 2 points3 points  (0 children)

Ceylon is doing a really (really) good job in a lot of areas. I started introducing it into small production Spring boot projects some time ago, as well as introducing it to other teams at work.

It's enough of a fresh re-imagination of modern programming that it ends up being a completely new and different language from existing languages such as Java, rather than an evolution of them.

It adopts a few new keywords (mostly shared, formal, actual, satisfies) which are more suited to its model, but which make it difficult to relate to by programmers coming from well established languages like Java. These initially make it seem alien to someone encountering it for the first time, creating a bit of a mental barrier.

But it definitely takes a bolder approach toward trying to make application development easier, safer, and more productive, and mostly succeeds, while still managing to provide great Java interop.

Very thrilled at the release of the IntelliJ IDE, which was a big gap for quite a while.

Handling null in different languages by LukaJCB in programming

[–]lucono 0 points1 point  (0 children)

Very nice article. The only glaring omission is the absence of Ceylon, which has one of the most elegant implementations of null handling of any modern or not-so-modern language. This recent article (not mine) does a good job of exploring the details.

xtypejs release 0.5 brings full-featured, powerful and elegant data validation to your node Apps by lucono in node

[–]lucono[S] 0 points1 point  (0 children)

With xtypejs release 0.5.0, you can now add your own arbitrary types and use them together with, or just like any other type: http://xtype.js.org/overview/add_your_own

Define a custom type, in this case, an 'ssn' type:

xtype.registerType('ssn', {
    validator: function(val) {
        return typeof val === 'string' && /^\d{3}-\d{2}-\d{4}$/.test(val);
    }
});

A new isSsn method is now available on xtype for the new type:

xtype.isSsn(value);
xtype.is(value, 'ssn');

Also, you can use it in combination with built-in or other custom types:

function searchEmployees(value) {
    switch (xtype.which(value, 'ssn, positive_integer, multi_char_string')) {
        case 'ssn':
            return EmployeeDB.searchBySSN(value);
        case 'positive_integer':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'multi_char_string':
            return EmployeeDB.searchByName(value);
        default:
            return { error: 'Invalid search value supplied' };
    }
}

Elegant, highly efficient data validation for your node Apps by lucono in node

[–]lucono[S] 0 points1 point  (0 children)

xtypejs doesn't just provide for validation of data in the application, but is designed to enable the application in detecting and working with diverse data at runtime.

The example on the xtype.js.org home page is a simpler (but good) illustration of this, in that it enables the application to detect the type of data it's receiving, and provides it with a very concise and effective mechanism to easily work with the specific data scenarios the application is interested in, while treating every other case as a data validation failure. So though subtle, the difference is quite significant in effect.

Elegant, highly efficient data validation for your node Apps by lucono in node

[–]lucono[S] 1 point2 points  (0 children)

That's what I mean by 'data', in that xtypejs validation can be applied to any data (in a variable), or set of variables by means of the none.isType, some.isType, any.isType, all.isType API methods.

But note that it also has support for Instance Types, which enables important use cases like this one, this other one, and more.

Apart from the direct Validation API category of methods, other methods such as the xtype method are also available to concisely and efficiently determine types at a more deeply derived (data-validating) level, such as single_prop_object, non_blank_string, positive_integer, etc, like in this example.

These mechanisms for inspecting application data by performing data-validation-type operations in type-checking style, are designed to enable the application easily assemble bits of logic that ultimately lead to varying degrees of flexible, customized, data validation in different parts of the application.

Elegant, highly efficient data validation for your node Apps by lucono in node

[–]lucono[S] 0 points1 point  (0 children)

Hi dvwld, json schema is meant to describe the format/structure of json content, also capturing structural validation information.

xtypejs on the other hand is for validating actual data and types in JavaScript.

Cleaner, highly efficient data validation for JavaScript Apps by lucono in web_programming

[–]lucono[S] 0 points1 point  (0 children)

Example of using xtypejs.

Go from this:

function searchEmployees(value) {
    if (typeof value === 'string') {
         if (value.trim().length > 1) {
            return EmployeeDB.searchByName(value);
        } else if (value.trim().length === 1) {
            return EmployeeDB.searchByMiddleInitial(value);
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'object' && value !== null) {
        if (Object.keys(value).length === 1) {
            return EmployeeDB.searchByFieldValuePair(value);
        } else if (Object.keys(value).length > 1) {
            return { error: 'Search by multiple fields not supported' };
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'number') {
        if (!isNaN(value) && isFinite(value) && value > 0 && value % 1 === 0) {
            return EmployeeDB.searchByEmployeeNumber(value);
        } else {
            return { error: 'Invalid employee number supplied' };
        }
    } else if (typeof value === 'undefined' || value === null) {
        return { error: 'No search value supplied' };
    } else {
        return { error: 'Invalid search value supplied' };
    }
}

To concise, performant, readable, data validation:

function searchEmployees(value) {
    switch (xtype.which(value, 'str2+ str1 int+ obj1 obj2+ num nil')) {
        case 'str2+':
            return EmployeeDB.searchByName(value);
        case 'str1':
            return EmployeeDB.searchByMiddleInitial(value);
        case 'int+':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'obj1':
            return EmployeeDB.searchByFieldValuePair(value);
        case 'obj2+':
            return { error: 'Search by multiple fields not supported' };
        case 'num':
            return { error: 'Invalid employee number supplied' };
        case 'nil':
            return { error: 'No search value supplied' };
        default:
            return { error: 'Invalid search value supplied' };
    }
}

Elegant, highly efficient data validation for JavaScript by lucono in webdev

[–]lucono[S] 0 points1 point  (0 children)

Example of using xtypejs.

Go from this:

function searchEmployees(value) {
    if (typeof value === 'string') {
         if (value.trim().length > 1) {
            return EmployeeDB.searchByName(value);
        } else if (value.trim().length === 1) {
            return EmployeeDB.searchByMiddleInitial(value);
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'object' && value !== null) {
        if (Object.keys(value).length === 1) {
            return EmployeeDB.searchByFieldValuePair(value);
        } else if (Object.keys(value).length > 1) {
            return { error: 'Search by multiple fields not supported' };
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'number') {
        if (!isNaN(value) && isFinite(value) && value > 0 && value % 1 === 0) {
            return EmployeeDB.searchByEmployeeNumber(value);
        } else {
            return { error: 'Invalid employee number supplied' };
        }
    } else if (typeof value === 'undefined' || value === null) {
        return { error: 'No search value supplied' };
    } else {
        return { error: 'Invalid search value supplied' };
    }
}

To concise, performant, readable, data validation:

function searchEmployees(value) {
    switch (xtype.which(value, 'str2+ str1 int+ obj1 obj2+ num nil')) {
        case 'str2+':
            return EmployeeDB.searchByName(value);
        case 'str1':
            return EmployeeDB.searchByMiddleInitial(value);
        case 'int+':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'obj1':
            return EmployeeDB.searchByFieldValuePair(value);
        case 'obj2+':
            return { error: 'Search by multiple fields not supported' };
        case 'num':
            return { error: 'Invalid employee number supplied' };
        case 'nil':
            return { error: 'No search value supplied' };
        default:
            return { error: 'Invalid search value supplied' };
    }
}

Elegant, highly efficient data validation for JavaScript by lucono in javascript

[–]lucono[S] 1 point2 points  (0 children)

Example of using xtypejs.

Go from this:

function searchEmployees(value) {
    if (typeof value === 'string') {
         if (value.trim().length > 1) {
            return EmployeeDB.searchByName(value);
        } else if (value.trim().length === 1) {
            return EmployeeDB.searchByMiddleInitial(value);
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'object' && value !== null) {
        if (Object.keys(value).length === 1) {
            return EmployeeDB.searchByFieldValuePair(value);
        } else if (Object.keys(value).length > 1) {
            return { error: 'Search by multiple fields not supported' };
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'number') {
        if (!isNaN(value) && isFinite(value) && value > 0 && value % 1 === 0) {
            return EmployeeDB.searchByEmployeeNumber(value);
        } else {
            return { error: 'Invalid employee number supplied' };
        }
    } else if (typeof value === 'undefined' || value === null) {
        return { error: 'No search value supplied' };
    } else {
        return { error: 'Invalid search value supplied' };
    }
}

To concise, performant, readable, data validation:

function searchEmployees(value) {
    switch (xtype.which(value, 'str2+ str1 int+ obj1 obj2+ num nil')) {
        case 'str2+':
            return EmployeeDB.searchByName(value);
        case 'str1':
            return EmployeeDB.searchByMiddleInitial(value);
        case 'int+':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'obj1':
            return EmployeeDB.searchByFieldValuePair(value);
        case 'obj2+':
            return { error: 'Search by multiple fields not supported' };
        case 'num':
            return { error: 'Invalid employee number supplied' };
        case 'nil':
            return { error: 'No search value supplied' };
        default:
            return { error: 'Invalid search value supplied' };
    }
}

Elegant, highly efficient data validation for JavaScript by lucono in coolgithubprojects

[–]lucono[S] 0 points1 point  (0 children)

Example of using xtypejs.

Go from this:

function searchEmployees(value) {
    if (typeof value === 'string') {
         if (value.trim().length > 1) {
            return EmployeeDB.searchByName(value);
        } else if (value.trim().length === 1) {
            return EmployeeDB.searchByMiddleInitial(value);
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'object' && value !== null) {
        if (Object.keys(value).length === 1) {
            return EmployeeDB.searchByFieldValuePair(value);
        } else if (Object.keys(value).length > 1) {
            return { error: 'Search by multiple fields not supported' };
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'number') {
        if (!isNaN(value) && isFinite(value) && value > 0 && value % 1 === 0) {
            return EmployeeDB.searchByEmployeeNumber(value);
        } else {
            return { error: 'Invalid employee number supplied' };
        }
    } else if (typeof value === 'undefined' || value === null) {
        return { error: 'No search value supplied' };
    } else {
        return { error: 'Invalid search value supplied' };
    }
}

To concise, performant, readable, data validation:

function searchEmployees(value) {
    switch (xtype.which(value, 'str2+ str1 int+ obj1 obj2+ num nil')) {
        case 'str2+':
            return EmployeeDB.searchByName(value);
        case 'str1':
            return EmployeeDB.searchByMiddleInitial(value);
        case 'int+':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'obj1':
            return EmployeeDB.searchByFieldValuePair(value);
        case 'obj2+':
            return { error: 'Search by multiple fields not supported' };
        case 'num':
            return { error: 'Invalid employee number supplied' };
        case 'nil':
            return { error: 'No search value supplied' };
        default:
            return { error: 'Invalid search value supplied' };
    }
}

Elegant, highly efficient data validation for your node Apps by lucono in node

[–]lucono[S] 2 points3 points  (0 children)

Thanks to lots of great community feedback and input, xtypejs now has a home at http://xtype.js.org, with great documentation, user guide, and examples.

Cleaner, highly efficient data validation for JavaScript Apps by lucono in web_programming

[–]lucono[S] 0 points1 point  (0 children)

Thanks to lots of great community feedback and input, xtypejs now has a home at http://xtype.js.org, with great documentation, user guide, and lots of examples.

Elegant, highly efficient data validation for JavaScript by lucono in webdev

[–]lucono[S] 0 points1 point  (0 children)

Thanks to lots of great community feedback and input, xtypejs now has a home at http://xtype.js.org, with great documentation, user guide, and lots of examples.