Skip to content

Conversation

@lucdion
Copy link
Member

@lucdion lucdion commented Oct 2, 2019

Improve method that validates width and height values. Now handle… gracefully NaN and Infinity values.


internal func validateWidth(_ width: CGFloat, context: Context) -> Bool {
if width < 0 {
guard width.isNormal && width >= 0 else {
Copy link

@own2pwn own2pwn Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can check just that width > 0, isNormal should handle case when the width is greater than zero. (just a quick remark)


internal func validateHeight(_ height: CGFloat, context: Context) -> Bool {
if height < 0 {
guard height.isNormal && height >= 0 else {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, maybe stick to if let a, b style and omit &&?

@lucdion lucdion merged commit 3cd8476 into master Oct 3, 2019
@lucdion lucdion deleted the feature/improve_width_height_value_validation branch October 3, 2019 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants