MSDN Library
EN
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.

Validate data

 

Updated: June 16, 2015

In a JavaScript backend mobile service, server scripts are used to enforce server-side validation rules. For example, the following insert script only allows the operation to succeed when the item being inserted has a numeric price property greater than zero. Otherwise, the script writes an error to the response by calling request.respond.

function insert(item, user, request) {
    if (typeof item.price === 'number' && item.price > 0) {
        request.execute();
    } else {
        request.respond(statusCodes.BAD_REQUEST, 'Price must be a positive number');
    }
}

For more information, see the Mobile Services script reference

Vis:
© 2016 Microsoft