Eksportér (0) Udskriv
Udvid alt
EN
Dette indhold er ikke tilgængeligt på dit sprog, men her er den engelske version.

Validate data

Updated: April 2, 2014

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:
© 2014 Microsoft