Skip to content

Instantly share code, notes, and snippets.

@stev
Created December 19, 2012 16:55
Show Gist options
  • Save stev/4338235 to your computer and use it in GitHub Desktop.
Save stev/4338235 to your computer and use it in GitHub Desktop.
<?php
// getValue - и есть правельное актуальное значение (собственно что от формы и требуется)
// getActualValue - только правельное значение но без (default)
// getRawValue - исходное значение
$prm = Primitive::integer('id')->
import(['id'=>1]);
var_dump(
$prm->getValue(), // int: 1
$prm->getRawValue(), // string: 1
$prm->getActualValue(), // int: 1
$prm->getError() // null
);
$prm = Primitive::integer('id')->
import(['id'=>'']);
var_dump(
$prm->getValue(), // null
$prm->getRawValue(), // string: ''
$prm->getActualValue(), // null
$prm->getError() // null
);
$prm = Primitive::integer('id')->
required()->
import(['id'=>'']);
var_dump(
$prm->getValue(), // null
$prm->getRawValue(), // string: ''
$prm->getActualValue(), // null
$prm->getError() // error:MISSING
);
$prm = Primitive::integer('id')->
setDefault(4)->
import(['id'=>'']);
var_dump(
$prm->getValue(), // 4
$prm->getRawValue(), // string: ''
$prm->getActualValue(), // null
$prm->getError() // null
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment