info = new FieldInfo("number", "Number", FieldType::NUMBER); } public function format(RecordData $input, RecordData $output): RecordData { $value = $input->get($this->name); if (!is_numeric($value)) { $newValue = null; } else { $newValue = number_format( $value, $this->decimals, ".", "" ); $newValue = $this->decimals === 0 ? (int)$newValue : floatval($newValue); } $output->set($this->name,$newValue); return $output; } public function failRequired(mixed $value): bool { return is_null($value); } public function failMin(mixed $value): bool { if (is_null($value)) { return false; } return $value < $this->min; } public function failMax(mixed $value): bool { if (is_null($value)) { return false; } return $value > $this->min; } public function isRequired(): bool { return $this->required; } public function toJsonSchema(): Property { return new TypeProperty( type: PropertyType::STRING, id: $this->name, title: Option::fromValue($this->label), description: Option::fromValue($this->help, ""), default: Option::fromValue($this->default, ""), minLength: Option::fromValue($this->min), maxLength: Option::fromValue($this->max), readOnly: Option::fromValue($this->readonly, false), enum: none(), comment: Option::fromValue($this->group, ""), format: none(), ); } }