Var denne side nyttig?
Din feedback på dette indhold er vigtigt. Giv os din mening.
Mere feedback?
1500 tegn tilbage
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: February 27, 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:
© 2015 Microsoft