# Sprawdź granice schematu numerycznego zamiast przyjmować całą przymusu

> Sprawdź Int, SmallInt, TinyInt i Number2 z native compact schemas, w tym wartości frakcyjne, zero i out-of-range wpisy.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: pl
Content-SHA256: a4c3ec473a411e6add043b7e188d6732075bb7e81820f9a1443595fb5804ba74
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

W `total5@0.0.19` wszystkie typy numeryczne wprowadzają kodowy numer. **`Int` nie gwarantuje integralnego**: `7.9` jest zachowany. `Number2` również zachowuje tę frakcję; nie interpretuje nazwy jako okrągłe do dwóch dziesiątkowych miejsc.

`TinyInt` akceptuje wartości od 0 do 255. `SmallInt` akceptuje od -32767 do 32767; w szczególności -32768 jest w tej wersji odrzucane. Te kontrole podtypów wymuszają granice, ale nie wymagają wartości całkowitych: `TinyInt` akceptuje `1.5`. Dla identyfikatorów, liczników lub ilości, które muszą być całkowite, zastosuj jawną kontrolę `Number.isInteger()`. Te obserwacje opisują tę wersję i testowane wartości, a nie semantykę kolumn SQL.

```js controllers/numbers.js
var schema = NEWSCHEMA('NumericBoundaries', '*integer:Int,*small:SmallInt,*tiny:TinyInt,*decimal:Number2');

exports.install = function() {
	ROUTE('POST /numbers/ @json', numbers);
};

function numbers($) {
	var result = schema.transform($.body);
	if (result.error) {
		$.response.status = 400;
		$.json({ error: 'invalid numeric input' });
		return;
	}
	$.json(result.response);
}
```
