for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace frictionlessdata\tableschema\Fields;
/**
* Class YearMonthField
* casts to array [year, month].
*/
class YearMonthField extends BaseField
{
protected function validateCastValue($val)
if (!is_array($val)) {
$val = explode('-', $val);
}
if (count($val) != 2) {
throw $this->getValidationException(null, $val);
} else {
list($year, $month) = $val;
if ($year == '' || $month == '') {
$year = (int) $year;
$month = (int) $month;
if ($month < 1 || $month > 12) {
return $this->getNativeYearMonth($year, $month);
public static function type()
return 'yearmonth';
protected function getNativeYearMonth($year, $month)
return [$year, $month];